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 
17 
24 {
25 public:
29  struct BodyPart {
30  HttpHeaders* headers{nullptr};
32 
33  // Must always have headers, stream is optional (can be empty)
34  explicit operator bool() const
35  {
36  return headers != nullptr;
37  }
38  };
39 
44 
45  MultipartStream(Producer delegate) : producer(delegate)
46  {
47  }
48 
50  {
51  delete bodyPart.headers;
52  delete bodyPart.stream;
53  }
54 
60  const char* getBoundary();
61 
62 protected:
64 
65 private:
66  Producer producer;
67  BodyPart bodyPart;
68  char boundary[16]{};
69  bool footerSent{false};
70 };
Encapsulates a set of HTTP header information.
Definition: HttpHeaders.h:35
Base class for read-only stream.
Definition: DataSourceStream.h:46
Base class for read-only stream which generates output from multiple source streams.
Definition: MultiStream.h:24
Read-only stream for creating HTTP multi-part content.
Definition: MultipartStream.h:24
~MultipartStream()
Definition: MultipartStream.h:49
IDataSourceStream * getNextStream() override
Inherited class must implement this.
MultipartStream(Producer delegate)
Definition: MultipartStream.h:45
const char * getBoundary()
Returns the generated boundary.
Each result item contains a set of headers plus content stream.
Definition: MultipartStream.h:29
IDataSourceStream * stream
Definition: MultipartStream.h:31
HttpHeaders * headers
Definition: MultipartStream.h:30