| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,6 +76,7 @@ char contentTypes[][2][32] = { | |||
| 76 | 76 | #include <SSLCert.hpp> | |
| 77 | 77 | #include <HTTPRequest.hpp> | |
| 78 | 78 | #include <HTTPResponse.hpp> | |
| 79 | + #include <util.hpp> | ||
| 79 | 80 | ||
| 80 | 81 | // We use the following struct to store GPIO events: | |
| 81 | 82 | #define MAX_EVENTS 20 | |
@@ -316,7 +317,7 @@ void handleSPIFFS(HTTPRequest * req, HTTPResponse * res) { | |||
| 316 | 317 | File file = SPIFFS.open(filename.c_str()); | |
| 317 | 318 | ||
| 318 | 319 | // Set length | |
| 319 | - res->setHeader("Content-Length", "" + file.size()); | ||
| 320 | + res->setHeader("Content-Length", httpsserver::intToString(file.size())); | ||
| 320 | 321 | ||
| 321 | 322 | // Content-Type is guessed using the definition of the contentTypes-table defined above | |
| 322 | 323 | int cTypeIdx = 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -643,7 +643,7 @@ void handleWebsocketHandshake(HTTPRequest * req, HTTPResponse * res) { | |||
| 643 | 643 | /** | |
| 644 | 644 | * Function used to compute the value of the Sec-WebSocket-Accept during Websocket handshake | |
| 645 | 645 | */ | |
| 646 | - std::string websocketKeyResponseHash(std::string key) { | ||
| 646 | + std::string websocketKeyResponseHash(std::string const &key) { | ||
| 647 | 647 | std::string newKey = key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | |
| 648 | 648 | uint8_t shaData[HTTPS_SHA1_LENGTH]; | |
| 649 | 649 | esp_sha(SHA1, (uint8_t*)newKey.data(), newKey.length(), shaData); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,7 +119,6 @@ class HTTPConnection : private ConnectionContext { | |||
| 119 | 119 | size_t readBuffer(byte* buffer, size_t length); | |
| 120 | 120 | size_t getCacheSize(); | |
| 121 | 121 | bool checkWebsocket(); | |
| 122 | - std::string websocketKeyResponseHash(std::string key); | ||
| 123 | 122 | ||
| 124 | 123 | // The receive buffer | |
| 125 | 124 | char _receiveBuffer[HTTPS_CONNECTION_DATA_CHUNK_SIZE]; | |
@@ -161,7 +160,7 @@ class HTTPConnection : private ConnectionContext { | |||
| 161 | 160 | ||
| 162 | 161 | void handleWebsocketHandshake(HTTPRequest * req, HTTPResponse * res); | |
| 163 | 162 | ||
| 164 | - std::string websocketKeyResponseHash(std::string key); | ||
| 163 | + std::string websocketKeyResponseHash(std::string const &key); | ||
| 165 | 164 | ||
| 166 | 165 | void validationMiddleware(HTTPRequest * req, HTTPResponse * res, std::function<void()> next); | |
| 167 | 166 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,10 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | 3 | namespace httpsserver { | |
| 4 | 4 | ||
| 5 | - HTTPHeader::HTTPHeader(const std::string name, const std::string value): | ||
| 6 | - _name(std::move(name)), | ||
| 7 | - _value(std::move(value)) { | ||
| 8 | - | ||
| 5 | + HTTPHeader::HTTPHeader(const std::string &name, const std::string &value): | ||
| 6 | + _name(name), | ||
| 7 | + _value(value) { | ||
| 8 | + Serial.printf("Header Constructor: %s=%s\n4", name.c_str(), value.c_str()); | ||
| 9 | 9 | } | |
| 10 | 10 | ||
| 11 | 11 | HTTPHeader::~HTTPHeader() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,13 +1,14 @@ | |||
| 1 | 1 | #ifndef SRC_HTTPHEADER_HPP_ | |
| 2 | 2 | #define SRC_HTTPHEADER_HPP_ | |
| 3 | + #include <Arduino.h> | ||
| 3 | 4 | ||
| 4 | 5 | #include <string> | |
| 5 | 6 | ||
| 6 | 7 | namespace httpsserver { | |
| 7 | 8 | ||
| 8 | 9 | class HTTPHeader { | |
| 9 | 10 | public: | |
| 10 | - HTTPHeader(const std::string name, const std::string value); | ||
| 11 | + HTTPHeader(const std::string &name, const std::string &value); | ||
| 11 | 12 | virtual ~HTTPHeader(); | |
| 12 | 13 | const std::string _name; | |
| 13 | 14 | const std::string _value; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ HTTPHeaders::~HTTPHeaders() { | |||
| 12 | 12 | delete _headers; | |
| 13 | 13 | } | |
| 14 | 14 | ||
| 15 | - HTTPHeader * HTTPHeaders::get(const std::string name) { | ||
| 15 | + HTTPHeader * HTTPHeaders::get(std::string const &name) { | ||
| 16 | 16 | for(std::vector<HTTPHeader*>::iterator header = _headers->begin(); header != _headers->end(); ++header) { | |
| 17 | 17 | if ((*header)->_name.compare(name)==0) { | |
| 18 | 18 | return (*header); | |
@@ -21,7 +21,7 @@ HTTPHeader * HTTPHeaders::get(const std::string name) { | |||
| 21 | 21 | return NULL; | |
| 22 | 22 | } | |
| 23 | 23 | ||
| 24 | - std::string HTTPHeaders::getValue(std::string name) { | ||
| 24 | + std::string HTTPHeaders::getValue(std::string const &name) { | ||
| 25 | 25 | for(std::vector<HTTPHeader*>::iterator header = _headers->begin(); header != _headers->end(); ++header) { | |
| 26 | 26 | if ((*header)->_name.compare(name)==0) { | |
| 27 | 27 | return ((*header)->_value); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,8 +17,8 @@ class HTTPHeaders { | |||
| 17 | 17 | HTTPHeaders(); | |
| 18 | 18 | virtual ~HTTPHeaders(); | |
| 19 | 19 | ||
| 20 | - HTTPHeader * get(std::string name); | ||
| 21 | - std::string getValue(std::string name); | ||
| 20 | + HTTPHeader * get(std::string const &name); | ||
| 21 | + std::string getValue(std::string const &name); | ||
| 22 | 22 | void set(HTTPHeader * header); | |
| 23 | 23 | ||
| 24 | 24 | std::vector<HTTPHeader *> * getAll(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,9 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | 3 | namespace httpsserver { | |
| 4 | 4 | ||
| 5 | - HTTPNode::HTTPNode(const std::string path, const HTTPNodeType nodeType, const std::string tag): | ||
| 6 | - _path(std::move(path)), | ||
| 7 | - _tag(std::move(tag)), | ||
| 5 | + HTTPNode::HTTPNode(std::string const &path, const HTTPNodeType nodeType, std::string const &tag): | ||
| 6 | + _path(path), | ||
| 7 | + _tag(tag), | ||
| 8 | 8 | _nodeType(nodeType) { | |
| 9 | 9 | ||
| 10 | 10 | // Create vector for valdiators | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ enum HTTPNodeType { | |||
| 19 | 19 | ||
| 20 | 20 | class HTTPNode { | |
| 21 | 21 | public: | |
| 22 | - HTTPNode(const std::string path, const HTTPNodeType nodeType, const std::string tag = ""); | ||
| 22 | + HTTPNode(const std::string &path, const HTTPNodeType nodeType, const std::string &tag = ""); | ||
| 23 | 23 | virtual ~HTTPNode(); | |
| 24 | 24 | ||
| 25 | 25 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ ResourceParameters * HTTPRequest::getParams() { | |||
| 36 | 36 | return _params; | |
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | - std::string HTTPRequest::getHeader(std::string name) { | ||
| 39 | + std::string HTTPRequest::getHeader(std::string const &name) { | ||
| 40 | 40 | HTTPHeader * h = _headers->get(name); | |
| 41 | 41 | if (h != NULL) { | |
| 42 | 42 | return h->_value; | |
@@ -45,7 +45,7 @@ std::string HTTPRequest::getHeader(std::string name) { | |||
| 45 | 45 | } | |
| 46 | 46 | } | |
| 47 | 47 | ||
| 48 | - void HTTPRequest::setHeader(std::string name, std::string value) { | ||
| 48 | + void HTTPRequest::setHeader(std::string const &name, std::string const &value) { | ||
| 49 | 49 | _headers->set(new HTTPHeader(name, value)); | |
| 50 | 50 | } | |
| 51 | 51 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments