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_builder.h
- Revision:
- 7:2e3eedb9ca5c
- Parent:
- 0:910f5949759f
- Child:
- 10:b017c7d2cf23
diff -r 112d72c60e07 -r 2e3eedb9ca5c source/http_request_builder.h --- 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++) {