Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RZ_A2M_Mbed_samples_20201012 RZ_A2M_Mbed_samples
Diff: source/https_request.h
- Revision:
- 29:383e9bfbfbed
- Parent:
- 23:15fa2726f793
- Child:
- 32:fa4d71265625
diff -r 9a04ed79d67e -r 383e9bfbfbed source/https_request.h
--- a/source/https_request.h Tue Mar 27 11:07:02 2018 +0200
+++ b/source/https_request.h Fri Aug 10 11:30:37 2018 +0100
@@ -53,7 +53,7 @@
const char* ssl_ca_pem,
http_method method,
const char* url,
- Callback<void(const char *at, size_t length)> body_callback = 0)
+ Callback<void(const char *at, uint32_t length)> body_callback = 0)
{
_parsed_url = new ParsedUrl(url);
_body_callback = body_callback;
@@ -79,7 +79,7 @@
HttpsRequest(TLSSocket* socket,
http_method method,
const char* url,
- Callback<void(const char *at, size_t length)> body_callback = 0)
+ Callback<void(const char *at, uint32_t length)> body_callback = 0)
{
_parsed_url = new ParsedUrl(url);
_body_callback = body_callback;
@@ -128,7 +128,7 @@
return NULL;
}
- size_t request_size = 0;
+ uint32_t request_size = 0;
char* request = _request_builder->build(body, body_size, request_size);
ret = send_buffer((const unsigned char*)request, request_size);
@@ -150,7 +150,7 @@
* @return An HttpResponse pointer on success, or NULL on failure.
* See get_error() for the error code.
*/
- HttpResponse* send(Callback<const void*(size_t*)> body_cb) {
+ HttpResponse* send(Callback<const void*(uint32_t*)> body_cb) {
nsapi_error_t ret;
@@ -161,7 +161,7 @@
set_header("Transfer-Encoding", "chunked");
- size_t request_size = 0;
+ uint32_t request_size = 0;
char* request = _request_builder->build(NULL, 0, request_size);
// first... send this request headers without the body
@@ -175,14 +175,14 @@
// ok... now it's time to start sending chunks...
while (1) {
- size_t size;
+ uint32_t size;
const void *buffer = body_cb(&size);
if (size == 0) break;
// so... size in HEX, \r\n, data, \r\n again
char size_buff[10]; // if sending length of more than 8 digits, you have another problem on a microcontroller...
- size_t size_buff_size = sprintf(size_buff, "%X\r\n", size);
+ uint32_t size_buff_size = sprintf(size_buff, "%X\r\n", size);
if ((total_send_count = send_buffer((const unsigned char*)size_buff, size_buff_size)) < 0) {
free(request);
_error = total_send_count;
@@ -299,7 +299,7 @@
return NSAPI_ERROR_OK;
}
- nsapi_size_or_error_t send_buffer(const unsigned char *buffer, size_t buffer_size) {
+ nsapi_size_or_error_t send_buffer(const unsigned char *buffer, uint32_t buffer_size) {
nsapi_size_or_error_t ret = mbedtls_ssl_write(_tlssocket->get_ssl_context(), (const unsigned char *) buffer, buffer_size);
if (ret < 0) {
@@ -330,10 +330,10 @@
/* Read data out of the socket */
while ((ret = mbedtls_ssl_read(_tlssocket->get_ssl_context(), (unsigned char *) recv_buffer, HTTP_RECEIVE_BUFFER_SIZE)) > 0) {
// Don't know if this is actually needed, but OK
- size_t _bpos = static_cast<size_t>(ret);
+ uint32_t _bpos = static_cast<uint32_t>(ret);
recv_buffer[_bpos] = 0;
- size_t nparsed = parser.execute((const char*)recv_buffer, _bpos);
+ uint32_t nparsed = parser.execute((const char*)recv_buffer, _bpos);
if (nparsed != _bpos) {
print_mbedtls_error("parser_error", nparsed);
// parser error...
@@ -373,7 +373,7 @@
TLSSocket* _tlssocket;
bool _we_created_the_socket;
- Callback<void(const char *at, size_t length)> _body_callback;
+ Callback<void(const char *at, uint32_t length)> _body_callback;
ParsedUrl* _parsed_url;
HttpRequestBuilder* _request_builder;
HttpResponse* _response;