Commit f1d7b14b authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Fix HTTP POST requests.

parent ebc6a2d9
...@@ -1508,11 +1508,10 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, ...@@ -1508,11 +1508,10 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
static const WCHAR szSetCookie[] = {'S','e','t','-','C','o','o','k','i','e',0 }; static const WCHAR szSetCookie[] = {'S','e','t','-','C','o','o','k','i','e',0 };
static const WCHAR szColon[] = { ':',' ',0 }; static const WCHAR szColon[] = { ':',' ',0 };
LPCWSTR *req; LPCWSTR *req;
LPWSTR p; LPWSTR p, szCookedHeaders = NULL;
int len, n; int len, n;
char *ascii_req; char *ascii_req;
TRACE("Going to url %s %s\n", debugstr_w(lpwhr->lpszHostName), debugstr_w(lpwhr->lpszPath)); TRACE("Going to url %s %s\n", debugstr_w(lpwhr->lpszHostName), debugstr_w(lpwhr->lpszPath));
loop_next = FALSE; loop_next = FALSE;
...@@ -1532,8 +1531,22 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, ...@@ -1532,8 +1531,22 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
lpwhr->lpszPath = fixurl; lpwhr->lpszPath = fixurl;
} }
/* add the headers the caller supplied */
if( lpszHeaders )
{
len = strlenW(lpszHeaders)+3;
szCookedHeaders = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR)*len );
strcpyW( szCookedHeaders, lpszHeaders );
/* make sure there's exactly one linebreak at the end of the string */
p = &szCookedHeaders[len-4];
while( (szCookedHeaders <= p) && ((*p == '\n') || (*p == '\r')) )
p--;
p[1] = 0;
}
/* allocate space for an array of all the string pointers to be added */ /* allocate space for an array of all the string pointers to be added */
len = (2 + HTTP_QUERY_MAX + lpwhr->nCustHeaders)*4 + 3; len = (HTTP_QUERY_MAX + lpwhr->nCustHeaders)*4 + 8;
req = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(LPCWSTR) ); req = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(LPCWSTR) );
/* add the verb, path and HTTP/1.0 */ /* add the verb, path and HTTP/1.0 */
...@@ -1542,6 +1555,11 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, ...@@ -1542,6 +1555,11 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
req[n++] = szSpace; req[n++] = szSpace;
req[n++] = lpwhr->lpszPath; req[n++] = lpwhr->lpszPath;
req[n++] = HTTPHEADER; req[n++] = HTTPHEADER;
if( szCookedHeaders )
{
req[n++] = szcrlf;
req[n++] = szCookedHeaders;
}
/* Append standard request headers */ /* Append standard request headers */
for (i = 0; i <= HTTP_QUERY_MAX; i++) for (i = 0; i <= HTTP_QUERY_MAX; i++)
...@@ -1584,8 +1602,10 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, ...@@ -1584,8 +1602,10 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
if( n > len ) if( n > len )
ERR("oops. buffer overrun\n"); ERR("oops. buffer overrun\n");
req[n] = NULL;
requestString = HTTP_build_req( req, 4 ); requestString = HTTP_build_req( req, 4 );
HeapFree( GetProcessHeap(), 0, req ); HeapFree( GetProcessHeap(), 0, req );
HeapFree( GetProcessHeap(), 0, szCookedHeaders );
/* /*
* Set (header) termination string for request * Set (header) termination string for request
...@@ -1602,9 +1622,6 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, ...@@ -1602,9 +1622,6 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
if (!HTTP_OpenConnection(lpwhr)) if (!HTTP_OpenConnection(lpwhr))
goto lend; goto lend;
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_SENDING_REQUEST, NULL, 0);
/* send the request as ASCII, tack on the optional data */ /* send the request as ASCII, tack on the optional data */
if( !lpOptional ) if( !lpOptional )
dwOptionalLength = 0; dwOptionalLength = 0;
...@@ -1614,8 +1631,14 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders, ...@@ -1614,8 +1631,14 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
WideCharToMultiByte( CP_ACP, 0, requestString, -1, WideCharToMultiByte( CP_ACP, 0, requestString, -1,
ascii_req, len, NULL, NULL ); ascii_req, len, NULL, NULL );
if( lpOptional ) if( lpOptional )
memcpy( &ascii_req[len], lpOptional, dwOptionalLength ); memcpy( &ascii_req[len-1], lpOptional, dwOptionalLength );
len += dwOptionalLength; len = (len + dwOptionalLength - 1);
ascii_req[len] = 0;
TRACE("full request -> %s\n", ascii_req );
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
INTERNET_STATUS_SENDING_REQUEST, NULL, 0);
NETCON_send(&lpwhr->netConnection, ascii_req, len, 0, &cnt); NETCON_send(&lpwhr->netConnection, ascii_req, len, 0, &cnt);
HeapFree( GetProcessHeap(), 0, ascii_req ); HeapFree( GetProcessHeap(), 0, ascii_req );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment