This library is used to make HTTP and HTTPS calls from mbed OS 5 applications.
Fork of mbed-http by
Diff: source/http_request_builder.h
- Revision:
- 7:2e3eedb9ca5c
- Parent:
- 0:910f5949759f
- Child:
- 10:b017c7d2cf23
--- a/source/http_request_builder.h Thu Feb 23 14:11:47 2017 +0100 +++ b/source/http_request_builder.h Fri Feb 24 11:20:16 2017 +0100 @@ -80,8 +80,14 @@ char* req = (char*)calloc(size + 1, 1); char* originalReq = req; - sprintf(req, "%s %s%s HTTP/1.1\r\n", method_str, parsed_url->path(), parsed_url->query()); - req += strlen(method_str) + 1 + strlen(parsed_url->path()) + strlen(parsed_url->query()) + 1 + 8 + 2; + if (strcmp(parsed_url->query(), "") == 0) { + sprintf(req, "%s %s HTTP/1.1\r\n", method_str, parsed_url->path()); + req += strlen(method_str) + 1 + strlen(parsed_url->path()) + 1 + 8 + 2; + } + else { + sprintf(req, "%s %s?%s HTTP/1.1\r\n", method_str, parsed_url->path(), parsed_url->query()); + req += strlen(method_str) + 1 + strlen(parsed_url->path()) + 1 + strlen(parsed_url->query()) + 1 + 8 + 2; + } typedef map<string, string>::iterator it_type; for(it_type it = headers.begin(); it != headers.end(); it++) {