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: MQTTGateway2 MQTTGatewayK64 http-example-wnc GuardRoom ... more
Revision 21:fcd2bfd31a39, committed 2017-12-14
- Comitter:
- Jan Jongboom
- Date:
- Thu Dec 14 16:19:22 2017 +0700
- Parent:
- 20:0e63d6a93c02
- Child:
- 22:71fc1b1894f8
- Commit message:
- Add port Host header if not 80/443
Changed in this revision
| source/http_request_builder.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/http_request_builder.h Sat Nov 18 14:03:26 2017 +0100
+++ b/source/http_request_builder.h Thu Dec 14 16:19:22 2017 +0700
@@ -28,7 +28,19 @@
HttpRequestBuilder(http_method a_method, ParsedUrl* a_parsed_url)
: method(a_method), parsed_url(a_parsed_url)
{
- set_header("Host", string(parsed_url->host()));
+ string host(parsed_url->host());
+
+ char port_str[10];
+ sprintf(port_str, ":%d", parsed_url->port());
+
+ if (strcmp(parsed_url->schema(), "http") == 0 && parsed_url->port() != 80) {
+ host += string(port_str);
+ }
+ else if (strcmp(parsed_url->schema(), "https") == 0 && parsed_url->port() != 443) {
+ host += string(port_str);
+ }
+
+ set_header("Host", host);
}
/**