From e0441f5fbe0f028038d66048113438aa8a938946 Mon Sep 17 00:00:00 2001 From: Kenny MacDermid Date: Fri, 3 Jan 2014 21:29:27 -0400 Subject: Send headers in first packet. Splitting up the writes causes the Host header to end up in a different packet than the requst line, making it harder to proxy. --- src/libwaitress/waitress.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/libwaitress') diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c index 9cf9b47..334591c 100644 --- a/src/libwaitress/waitress.c +++ b/src/libwaitress/waitress.c @@ -914,23 +914,20 @@ static WaitressReturn_t WaitressSendRequest (WaitressHandle_t *waith) { /* send request */ if (WaitressProxyEnabled (waith) && !waith->url.tls) { snprintf (buf, WAITRESS_BUFFER_SIZE, - "%s http://%s:%s/%s HTTP/" WAITRESS_HTTP_VERSION "\r\n", + "%s http://%s:%s/%s HTTP/" WAITRESS_HTTP_VERSION "\r\n" + "Host: %s\r\nUser-Agent: " PACKAGE "\r\nConnection: Close\r\n", (waith->method == WAITRESS_METHOD_GET ? "GET" : "POST"), waith->url.host, - WaitressDefaultPort (&waith->url), path); + WaitressDefaultPort (&waith->url), path, waith->url.host); } else { snprintf (buf, WAITRESS_BUFFER_SIZE, - "%s /%s HTTP/" WAITRESS_HTTP_VERSION "\r\n", + "%s /%s HTTP/" WAITRESS_HTTP_VERSION "\r\n" + "Host: %s\r\nUser-Agent: " PACKAGE "\r\nConnection: Close\r\n", (waith->method == WAITRESS_METHOD_GET ? "GET" : "POST"), - path); + path, waith->url.host); } WRITE_RET (buf, strlen (buf)); - snprintf (buf, WAITRESS_BUFFER_SIZE, - "Host: %s\r\nUser-Agent: " PACKAGE "\r\nConnection: Close\r\n", - waith->url.host); - WRITE_RET (buf, strlen (buf)); - if (waith->method == WAITRESS_METHOD_POST && waith->postData != NULL) { snprintf (buf, WAITRESS_BUFFER_SIZE, "Content-Length: %zu\r\n", strlen (waith->postData)); -- cgit v1.2.3