wininet: Remove the content length header after the request is sent.
Hans Leidekker
hans at codeweavers.com
Mon Oct 13 06:57:16 CDT 2014
This ensures that a new content length header is inserted when the request is reused.
---
dlls/wininet/http.c | 39 ++++++++++++++++-----------------------
1 file changed, 16 insertions(+), 23 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 40f8d9a..9e6960a 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -549,10 +549,19 @@ static void wininet_zfree(voidpf opaque, voidpf address)
heap_free(address);
}
+static void remove_header( http_request_t *request, const WCHAR *str, BOOL from_request )
+{
+ int index;
+ EnterCriticalSection( &request->headers_section );
+ index = HTTP_GetCustomHeaderIndex( request, str, 0, from_request );
+ if (index != -1) HTTP_DeleteCustomHeader( request, index );
+ LeaveCriticalSection( &request->headers_section );
+}
+
static DWORD init_gzip_stream(http_request_t *req, BOOL is_gzip)
{
gzip_stream_t *gzip_stream;
- int index, zres;
+ int zres;
gzip_stream = heap_alloc_zero(sizeof(gzip_stream_t));
if(!gzip_stream)
@@ -569,11 +578,7 @@ static DWORD init_gzip_stream(http_request_t *req, BOOL is_gzip)
return ERROR_OUTOFMEMORY;
}
- EnterCriticalSection( &req->headers_section );
- index = HTTP_GetCustomHeaderIndex(req, szContent_Length, 0, FALSE);
- if(index != -1)
- HTTP_DeleteCustomHeader(req, index);
- LeaveCriticalSection( &req->headers_section );
+ remove_header(req, szContent_Length, FALSE);
if(req->read_size) {
memcpy(gzip_stream->buf, req->read_buf+req->read_pos, req->read_size);
@@ -4109,7 +4114,6 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl)
{
http_session_t *session = request->session;
WCHAR path[INTERNET_MAX_PATH_LENGTH];
- int index;
if(lpszUrl[0]=='/')
{
@@ -4222,15 +4226,8 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl)
}
}
- EnterCriticalSection( &request->headers_section );
-
- /* Remove custom content-type/length headers on redirects. */
- index = HTTP_GetCustomHeaderIndex(request, szContent_Type, 0, TRUE);
- if (index != -1) HTTP_DeleteCustomHeader(request, index);
- index = HTTP_GetCustomHeaderIndex(request, szContent_Length, 0, TRUE);
- if (index != -1) HTTP_DeleteCustomHeader(request, index);
-
- LeaveCriticalSection( &request->headers_section );
+ /* Remove custom content-type header on redirects. */
+ remove_header(request, szContent_Type, TRUE);
return ERROR_SUCCESS;
}
@@ -5060,6 +5057,8 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
INTERNET_STATUS_REQUEST_SENT,
&len, sizeof(DWORD));
+ remove_header(request, szContent_Length, TRUE);
+
if (bEndRequest)
{
DWORD dwBufferSize;
@@ -5193,8 +5192,6 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
}
if (secure_proxy_connect && request->status_code == HTTP_STATUS_OK)
{
- int index;
-
res = NETCON_secure_connect(request->netconn, request->server);
if (res != ERROR_SUCCESS)
{
@@ -5202,11 +5199,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
http_release_netconn( request, FALSE );
break;
}
- EnterCriticalSection( &request->headers_section );
- index = HTTP_GetCustomHeaderIndex(request, szProxy_Authorization, 0, TRUE);
- if (index != -1) HTTP_DeleteCustomHeader(request, index);
- LeaveCriticalSection( &request->headers_section );
-
+ remove_header(request, szProxy_Authorization, TRUE);
destroy_authinfo(request->proxyAuthInfo);
request->proxyAuthInfo = NULL;
--
2.1.1
More information about the wine-patches
mailing list