fix the problem http request with '\0' and fixx query string in url

Fork of mbed-http by sandbox

Embed: (wiki syntax)

« Back to documentation index

HttpRequest Class Reference

HttpRequest Class Reference

HttpRequest implements the logic for interacting with HTTPS servers. More...

#include <http_request.h>

Public Member Functions

 HttpRequest (NetworkInterface *aNetwork, http_method aMethod, const char *url, Callback< void(const char *at, size_t length)> aBodyCallback=0)
 HttpRequest Constructor.
 ~HttpRequest ()
 HttpRequest Constructor.
HttpResponse * send (const void *body=NULL, nsapi_size_t body_size=0)
 Execute the request and receive the response.
void set_header (string key, string value)
 Set a header for the request.
nsapi_error_t get_error ()
 Get the error code.

Detailed Description

HttpRequest implements the logic for interacting with HTTPS servers.

Definition at line 40 of file http_request.h.


Constructor & Destructor Documentation

HttpRequest ( NetworkInterface *  aNetwork,
http_method  aMethod,
const char *  url,
Callback< void(const char *at, size_t length)>  aBodyCallback = 0 
)

HttpRequest Constructor.

Parameters:
[in]aNetworkThe network interface
[in]aMethodHTTP method to use
[in]urlURL to the resource
[in]aBodyCallbackCallback 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.

Definition at line 52 of file http_request.h.

~HttpRequest (  )

HttpRequest Constructor.

Definition at line 65 of file http_request.h.


Member Function Documentation

nsapi_error_t get_error (  )

Get the error code.

When send() fails, this error is set.

Definition at line 181 of file http_request.h.

HttpResponse* send ( const void *  body = NULL,
nsapi_size_t  body_size = 0 
)

Execute the request and receive the response.

Definition at line 84 of file http_request.h.

void set_header ( string  key,
string  value 
)

Set a header for the request.

The 'Host' and 'Content-Length' headers are set automatically. Setting the same header twice will overwrite the previous entry.

Parameters:
[in]keyHeader key
[in]valueHeader value

Definition at line 172 of file http_request.h.