Merge pull request #36 from thp/http-remove-default-port

http.h: Do not add port 80 to Host header
This commit is contained in:
Mattias Gustavsson
2022-09-10 12:02:25 +02:00
committed by GitHub
+4 -2
View File
@@ -420,7 +420,8 @@ http_t* http_get( char const* url, void* memctx )
internal->request_header_large = (char*) HTTP_MALLOC( memctx, request_header_len + 1 );
request_header = internal->request_header_large;
}
sprintf( request_header, "GET %s HTTP/1.0\r\nHost: %s:%s\r\n\r\n", resource, address, port );
int default_http_port = (strcmp(port, "80") == 0);
sprintf( request_header, "GET %s HTTP/1.0\r\nHost: %s%s%s\r\n\r\n", resource, address, default_http_port ? "" : ":", default_http_port ? "" : port );
return &internal->http;
}
@@ -458,7 +459,8 @@ http_t* http_post( char const* url, void const* data, size_t size, void* memctx
internal->request_header_large = (char*) HTTP_MALLOC( memctx, request_header_len + 1 );
request_header = internal->request_header_large;
}
sprintf( request_header, "POST %s HTTP/1.0\r\nHost: %s:%s\r\nContent-Length: %d\r\n\r\n", resource, address, port,
int default_http_port = (strcmp(port, "80") == 0);
sprintf( request_header, "POST %s HTTP/1.0\r\nHost: %s%s%s\r\nContent-Length: %d\r\n\r\n", resource, address, default_http_port ? "" : ":", default_http_port ? "" : port,
(int) size );
internal->request_data_size = size;