diff --git a/http.h b/http.h index f6e001d..c51c1d6 100644 --- a/http.h +++ b/http.h @@ -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;