HTTP and HTTPS library for Mbed OS 5
Dependents: RZ_A2M_Mbed_samples_20201012 RZ_A2M_Mbed_samples
Revision 40:8fe3b866f1f4, committed 2020-09-16
- Comitter:
- RyoheiHagimoto@os.mbed.com
- Date:
- Wed Sep 16 14:40:45 2020 +0900
- Parent:
- 39:a8d157986ad8
- Commit message:
- Modified some API for Mbed OS 6.
Changed in this revision
--- a/source/http_parsed_url.h Mon Aug 12 11:45:31 2019 +0200 +++ b/source/http_parsed_url.h Wed Sep 16 14:40:45 2020 +0900 @@ -30,7 +30,7 @@ char* value; if (parsed_url.field_set & (1 << ix)) { value = (char*)calloc(parsed_url.field_data[ix].len + 1, 1); - memcpy(value, url + parsed_url.field_data[ix].off, + memcpy((void*)value, url + parsed_url.field_data[ix].off, parsed_url.field_data[ix].len); } else { @@ -45,7 +45,7 @@ case UF_USERINFO: _userinfo = value; break; default: // PORT is already parsed, FRAGMENT is not relevant for HTTP requests - free(value); + free((void*)value); break; } } @@ -68,11 +68,11 @@ } ~ParsedUrl() { - if (_schema) free(_schema); - if (_host) free(_host); - if (_path) free(_path); - if (_query) free(_query); - if (_userinfo) free(_userinfo); + if (_schema) free((void*)_schema); + if (_host) free((void*)_host); + if (_path) free((void*)_path); + if (_query) free((void*)_query); + if (_userinfo) free((void*)_userinfo); } uint16_t port() const { return _port; }
--- a/source/http_request.h Mon Aug 12 11:45:31 2019 +0200 +++ b/source/http_request.h Wed Sep 16 14:40:45 2020 +0900 @@ -93,7 +93,11 @@ protected: virtual nsapi_error_t connect_socket(char *host, uint16_t port) { - return ((TCPSocket*)_socket)->connect(host, port); + SocketAddress tcp_addr; + NetworkInterface::get_default_instance()->gethostbyname(host, &tcp_addr); + tcp_addr.set_port(port); + + return ((TCPSocket*)_socket)->connect(tcp_addr); } };
--- a/source/http_request_base.h Mon Aug 12 11:45:31 2019 +0200 +++ b/source/http_request_base.h Wed Sep 16 14:40:45 2020 +0900 @@ -255,7 +255,7 @@ nsapi_size_or_error_t send_buffer(char* buffer, uint32_t buffer_size) { nsapi_size_or_error_t total_send_count = 0; - while (total_send_count < buffer_size) { + while ((uint32_t)total_send_count < buffer_size) { // get a slice of the buffer char *buffer_slice = buffer + total_send_count;
--- a/source/https_request.h Mon Aug 12 11:45:31 2019 +0200 +++ b/source/https_request.h Wed Sep 16 14:40:45 2020 +0900 @@ -91,7 +91,11 @@ protected: virtual nsapi_error_t connect_socket(char *host, uint16_t port) { - return ((TLSSocket*)_socket)->connect(host, port); + SocketAddress tcp_addr; + NetworkInterface::get_default_instance()->gethostbyname(host, &tcp_addr); + tcp_addr.set_port(port); + + return ((TLSSocket*)_socket)->connect(tcp_addr); } };