Fork of SandBox's original mbed-http (https://os.mbed.com/teams/sandbox/code/mbed-http/) and update for MbedOS6+ Content of TESTS folder was replaced with basic examples form original SandBox's HelloWorld
Diff: source/http_request.h
- Revision:
- 36:d46da03715db
- Parent:
- 32:fa4d71265625
- Child:
- 37:98d83ca14b7b
diff -r b3ee394d1d2e -r d46da03715db source/http_request.h --- a/source/http_request.h Fri Aug 09 09:58:57 2019 +0200 +++ b/source/http_request.h Fri Aug 09 10:36:07 2019 +0200 @@ -87,6 +87,52 @@ _we_created_socket = false; } + /** + * HttpRequest Constructor + * + * @param[in] network The network interface + * @param[in] method HTTP method to use + * @param[in] url Parsed URL to the resource + * @param[in] bodyCallback Callback on which to retrieve chunks of the response body. + If not set, the complete body will be allocated on the HttpResponse object, + which might use lots of memory. + */ + HttpRequest(NetworkInterface* network, http_method method, ParsedUrl* url, Callback<void(const char *at, uint32_t length)> bodyCallback = 0) + : HttpRequestBase(NULL, bodyCallback) + { + _error = 0; + _response = NULL; + + _parsed_url = url; + _request_builder = new HttpRequestBuilder(method, _parsed_url); + + _socket = new TCPSocket(); + ((TCPSocket*)_socket)->open(network); + _we_created_socket = true; + } + + /** + * HttpRequest Constructor + * + * @param[in] socket An open TCPSocket + * @param[in] method HTTP method to use + * @param[in] url URL to the resource + * @param[in] bodyCallback Callback on which to retrieve chunks of the response body. + If not set, the complete body will be allocated on the HttpResponse object, + which might use lots of memory. + */ + HttpRequest(TCPSocket* socket, http_method method, ParsedUrl* url, Callback<void(const char *at, uint32_t length)> bodyCallback = 0) + : HttpRequestBase(socket, bodyCallback) + { + _error = 0; + _response = NULL; + + _parsed_url = url; + _request_builder = new HttpRequestBuilder(method, _parsed_url); + + _we_created_socket = false; + } + virtual ~HttpRequest() { }