Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
68 lines (54 loc) · 1.98 KB

File metadata and controls

68 lines (54 loc) · 1.98 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef SRC_HTTPBODYPARSER_HPP_
#define SRC_HTTPBODYPARSER_HPP_
#include <Arduino.h>
#include <string>
#include "HTTPRequest.hpp"
namespace httpsserver {
/**
* Superclass for various body parser implementations that can be used to
* interpret http-specific bodies (like x-www-form-urlencoded or multipart/form-data)
*
* To allow for arbitrary body length, the interface of the body parser provides access
* to one underlying "field" at a time. A field may be a value of the urlencoded string
* or a part of a multipart message.
*
* Using next() proceeds to the next field.
*/
class HTTPBodyParser {
public:
const size_t unknownLength = 0x7ffffffe;
HTTPBodyParser(HTTPRequest * req): _request(req) {};
virtual ~HTTPBodyParser() {}
/**
* Proceeds to the next field of the body
*
* If a field has not been read completely, the remaining content is discarded.
*
* Returns true iff proceeding to the next field succeeded (ie there was a next field)
*/
virtual bool nextField() = 0;
/** Returns the name of the current field */
virtual std::string getFieldName() = 0;
/** Returns the filename of the current field or an empty string */
virtual std::string getFieldFilename() = 0;
/**
* Returns the mime type of the current field.
*
* Note: This value is set by the client. It can be altered maliciously. Do NOT rely on it
* for anything that affects the security of your device or other clients connected to it!
*
* Not every BodyParser might provide this value, usually it's set to something like text/plain then
*/
virtual std::string getFieldMimeType() = 0;
/**
* Reads a maximum of bufferSize bytes into buffer and returns the actual amount of bytes that have been read
*/
virtual size_t read(byte* buffer, size_t bufferSize) = 0;
/** Returns true when all field data has been read */
virtual bool endOfField() = 0;
protected:
/** The underlying request */
HTTPRequest * _request;
};
} // namespace httpserver
#endif
Morty Proxy This is a proxified and sanitized view of the page, visit original site.