fix superfluous \r\n after body
Fork of mbed-http by
Diff: source/http_request_builder.h
- Revision:
- 21:fcd2bfd31a39
- Parent:
- 10:b017c7d2cf23
- Child:
- 22:6c9da880cccd
--- 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);
}
/**
