-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored HttpClient, HttpServer and WebsocketConnection. (#1112)
- Better Code Design - Faster and powerful HttpParser used in both HttpClient and Server - Support for pipelinging in both HttpClient and HttpServer - Suppot for connection reusage for both HttpClient and HttpServer - SSL session resumption support for HttpClient and HttpServer - Added ResourceTree to the HttpServer to allow more flexible definition of resources - Added streaming support to both Http and WebSocket processing. - rBootHttpUpdate should fail now as early as possible. - Changed the ContentType code to allow easier definition of new mime types. ## Backwards-Incompatible changes - WebSocket is renamed to WebSocketConnection to reflect better its meaning and intended use. - Removed the tightly coupled websocket methods inside the HttpServer. You can use WebSocketResource and add it to the HttpServer resource tree to achieve the same results. - Moved writeInit(), writeFlash(const u8 *data, u16 size) and writeEnd() methods from rBootHttpUpdate to rBootItemOutputStream. - TemplateFileStream::setVarsFromRequest needs to be refactored completely. The current code couples TemplateFileStream to HttpRequest, which is too restrictive. TemplateFileStream::setVars method should be introduced that accepts HashMap<String,String> - HttpRequest::getRequestMethod() is removed. Use HttpRequest::method instead. - CommandExecutor with WebsocketConnection won't work.
- Loading branch information
Showing
73 changed files
with
8,321 additions
and
1,932 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/**** | ||
* Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. | ||
* Created 2015 by Skurydin Alexey | ||
* http://github.com/anakod/Sming | ||
* | ||
* HttpServerResource | ||
* | ||
* @author: 2017 - Slavey Karadzhov <[email protected]> | ||
* | ||
* All files of the Sming Core are provided under the LGPL v3 license. | ||
****/ | ||
|
||
#ifndef _SMING_CORE_HTTP_COMMON_H_ | ||
#define _SMING_CORE_HTTP_COMMON_H_ | ||
|
||
#define ENABLE_HTTP_REQUEST_AUTH 1 | ||
|
||
#include "../../Wiring/WString.h" | ||
#include "../../Wiring/WHashMap.h" | ||
#include "../../Delegate.h" | ||
#include "../../Wiring/FILO.h" | ||
#include "../WebConstants.h" | ||
#include "../URL.h" | ||
|
||
#ifndef HTTP_MAX_HEADER_SIZE | ||
#define HTTP_MAX_HEADER_SIZE (8*1024) | ||
#endif | ||
|
||
/* Number of maximum tcp connections to be kept in the pool */ | ||
#ifndef HTTP_REQUEST_POOL_SIZE | ||
#define HTTP_REQUEST_POOL_SIZE 20 | ||
#endif | ||
|
||
#include "../http-parser/http_parser.h" | ||
|
||
/** | ||
* WARNING: For the moment the name "SimpleConcurrentQueue" is very misleading. | ||
*/ | ||
template<typename T, int rawSize> | ||
class SimpleConcurrentQueue: public FIFO<T, rawSize> { | ||
public: | ||
virtual const T& operator[](unsigned int) const { } | ||
virtual T& operator[](unsigned int) { } | ||
|
||
T peek() const | ||
{ | ||
if(!FIFO<T, rawSize>::numberOfElements) { | ||
return NULL; | ||
} | ||
|
||
return FIFO<T, rawSize>::peek(); | ||
} | ||
|
||
T dequeue() | ||
{ | ||
if(!FIFO<T, rawSize>::numberOfElements) { | ||
return NULL; | ||
} | ||
|
||
return FIFO<T, rawSize>::dequeue(); | ||
} | ||
}; | ||
|
||
typedef HashMap<String, String> HttpParams; | ||
typedef HashMap<String, String> HttpHeaders; | ||
typedef enum http_method HttpMethod; | ||
|
||
#endif /* _SMING_CORE_HTTP_COMMON_H_ */ |
Oops, something went wrong.