1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

Add header access using same method as arguments 2

based on @brianensor PR
+sample and some sanity check
This commit is contained in:
luc
2015-10-28 13:58:53 +08:00
parent fbae22f86b
commit ee0b8621f3
4 changed files with 197 additions and 0 deletions

View File

@ -83,6 +83,12 @@ public:
String argName(int i); // get request argument name by number
int args(); // get arguments count
bool hasArg(const char* name); // check if argument exists
void collectHeaders(const char* headerKeys[], const size_t headerKeysCount); // set the request headers to collect
String header(const char* name); // get request header value by name
String header(int i); // get request header value by number
String headerName(int i); // get request header name by number
int headers(); // get header count
bool hasHeader(const char* name); // check if header exists
String hostHeader(); // get request host header if available or empty String if not
@ -124,6 +130,7 @@ protected:
void _uploadWriteByte(uint8_t b);
uint8_t _uploadReadByte(WiFiClient& client);
void _prepareHeader(String& response, int code, const char* content_type, size_t contentLength);
bool _collectHeader(const char* headerName, const char* headerValue);
struct RequestArgument {
String key;
@ -140,6 +147,8 @@ protected:
RequestArgument* _currentArgs;
HTTPUpload _currentUpload;
RequestArgument* _currentHeaders;
size_t _headerKeysCount;
size_t _contentLength;
String _responseHeaders;