winhttp: Add accept types to the request headers.
This commit is contained in:
parent
9237479d22
commit
050058c5bf
dlls/winhttp
|
@ -1031,8 +1031,13 @@ static BOOL send_request( request_t *request, LPCWSTR headers, DWORD headers_len
|
|||
WCHAR *req = NULL;
|
||||
char *req_ascii;
|
||||
int bytes_sent;
|
||||
DWORD len;
|
||||
DWORD len, i, flags;
|
||||
|
||||
flags = WINHTTP_ADDREQ_FLAG_ADD|WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
|
||||
for (i = 0; i < request->num_accept_types; i++)
|
||||
{
|
||||
process_header( request, attr_accept, request->accept_types[i], flags, TRUE );
|
||||
}
|
||||
if (session->agent)
|
||||
process_header( request, attr_user_agent, session->agent, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE );
|
||||
|
||||
|
@ -2422,6 +2427,8 @@ static HRESULT WINAPI winhttp_request_Open(
|
|||
BSTR url,
|
||||
VARIANT async )
|
||||
{
|
||||
static const WCHAR typeW[] = {'*','/','*',0};
|
||||
static const WCHAR *acceptW[] = {typeW, NULL};
|
||||
struct winhttp_request *request = impl_from_IWinHttpRequest( iface );
|
||||
HINTERNET hsession = NULL, hconnect = NULL, hrequest;
|
||||
URL_COMPONENTS uc;
|
||||
|
@ -2461,7 +2468,7 @@ static HRESULT WINAPI winhttp_request_Open(
|
|||
err = get_last_error();
|
||||
goto error;
|
||||
}
|
||||
if (!(hrequest = WinHttpOpenRequest( hconnect, method, path, NULL, NULL, NULL, 0 )))
|
||||
if (!(hrequest = WinHttpOpenRequest( hconnect, method, path, NULL, NULL, acceptW, 0 )))
|
||||
{
|
||||
err = get_last_error();
|
||||
goto error;
|
||||
|
|
|
@ -527,7 +527,7 @@ end:
|
|||
static void request_destroy( object_header_t *hdr )
|
||||
{
|
||||
request_t *request = (request_t *)hdr;
|
||||
DWORD i;
|
||||
unsigned int i;
|
||||
|
||||
TRACE("%p\n", request);
|
||||
|
||||
|
@ -544,6 +544,8 @@ static void request_destroy( object_header_t *hdr )
|
|||
heap_free( request->headers[i].value );
|
||||
}
|
||||
heap_free( request->headers );
|
||||
for (i = 0; i < request->num_accept_types; i++) heap_free( request->accept_types[i] );
|
||||
heap_free( request->accept_types );
|
||||
heap_free( request );
|
||||
}
|
||||
|
||||
|
@ -859,6 +861,39 @@ static const object_vtbl_t request_vtbl =
|
|||
request_set_option
|
||||
};
|
||||
|
||||
static BOOL store_accept_types( request_t *request, const WCHAR **accept_types )
|
||||
{
|
||||
const WCHAR **types = accept_types;
|
||||
int i;
|
||||
|
||||
if (!types) return TRUE;
|
||||
while (*types)
|
||||
{
|
||||
request->num_accept_types++;
|
||||
types++;
|
||||
}
|
||||
if (!request->num_accept_types) return TRUE;
|
||||
if (!(request->accept_types = heap_alloc( request->num_accept_types * sizeof(WCHAR *))))
|
||||
{
|
||||
request->num_accept_types = 0;
|
||||
return FALSE;
|
||||
}
|
||||
types = accept_types;
|
||||
for (i = 0; i < request->num_accept_types; i++)
|
||||
{
|
||||
if (!(request->accept_types[i] = strdupW( *types )))
|
||||
{
|
||||
for (; i >= 0; i--) heap_free( request->accept_types[i] );
|
||||
heap_free( request->accept_types );
|
||||
request->accept_types = NULL;
|
||||
request->num_accept_types = 0;
|
||||
return FALSE;
|
||||
}
|
||||
types++;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* WinHttpOpenRequest (winhttp.@)
|
||||
*/
|
||||
|
@ -926,6 +961,7 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
|
|||
|
||||
if (!version || !version[0]) version = http1_1;
|
||||
if (!(request->version = strdupW( version ))) goto end;
|
||||
if (!(store_accept_types( request, types ))) goto end;
|
||||
|
||||
if (!(hrequest = alloc_handle( &request->hdr ))) goto end;
|
||||
request->hdr.handle = hrequest;
|
||||
|
|
|
@ -157,6 +157,8 @@ typedef struct
|
|||
DWORD content_read; /* bytes read so far */
|
||||
header_t *headers;
|
||||
DWORD num_headers;
|
||||
WCHAR **accept_types;
|
||||
DWORD num_accept_types;
|
||||
} request_t;
|
||||
|
||||
typedef struct _task_header_t task_header_t;
|
||||
|
|
Loading…
Reference in New Issue