MultipartStream.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * MultipartStream.h
8  *
9  * @author Slavey Karadzhov <slaff@attachix.com>
10  *
11  ****/
12 
13 #pragma once
14 
15 #include "MultiStream.h"
17 
25 typedef struct {
26  HttpHeaders* headers = nullptr;
27  IDataSourceStream* stream = nullptr;
29 
31 
33 {
34 public:
35  MultipartStream(HttpPartProducerDelegate delegate) : producer(delegate)
36  {
37  }
38 
44  const char* getBoundary();
45 
46 protected:
48  {
49  result = producer();
50  return result.stream;
51  }
52 
53  void onNextStream() override;
54  bool onCompleted() override;
55 
56 private:
57  HttpPartProducerDelegate producer;
58  HttpPartResult result;
59 
60  char boundary[16] = {0};
61 };
62 
MultipartStream(HttpPartProducerDelegate delegate)
Definition: MultipartStream.h:35
Definition: MultiStream.h:18
Base class for data source stream.
Definition: DataSourceStream.h:39
const char * getBoundary()
Returns the generated boundary.
Encapsulates a set of HTTP header information.
Definition: HttpHeaders.h:96
void onNextStream() override
Definition: MultipartStream.h:32
IDataSourceStream * stream
Definition: MultipartStream.h:27
bool onCompleted() override
IDataSourceStream * getNextStream() override
Definition: MultipartStream.h:47
Delegate< HttpPartResult()> HttpPartProducerDelegate
Definition: MultipartStream.h:30
Multipart stream class.
Definition: MultipartStream.h:25