winhttp: Store Accept headers like the other headers.
Based on a patch by Sebastian Lackner. Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c81fa01751
commit
2f75297036
|
@ -398,8 +398,7 @@ static BOOL delete_header( struct request *request, DWORD index )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL process_header( struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags,
|
BOOL process_header( struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only )
|
||||||
BOOL request_only )
|
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
struct header hdr;
|
struct header hdr;
|
||||||
|
@ -2180,16 +2179,11 @@ static BOOL send_request( struct request *request, const WCHAR *headers, DWORD h
|
||||||
struct session *session = connect->session;
|
struct session *session = connect->session;
|
||||||
char *wire_req;
|
char *wire_req;
|
||||||
int bytes_sent;
|
int bytes_sent;
|
||||||
DWORD len, i, flags;
|
DWORD len;
|
||||||
|
|
||||||
clear_response_headers( request );
|
clear_response_headers( request );
|
||||||
drain_content( request );
|
drain_content( request );
|
||||||
|
|
||||||
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)
|
if (session->agent)
|
||||||
process_header( request, attr_user_agent, session->agent, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE );
|
process_header( request, attr_user_agent, session->agent, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE );
|
||||||
|
|
||||||
|
|
|
@ -626,8 +626,6 @@ static void request_destroy( struct object_header *hdr )
|
||||||
heap_free( request->headers[i].value );
|
heap_free( request->headers[i].value );
|
||||||
}
|
}
|
||||||
heap_free( request->headers );
|
heap_free( request->headers );
|
||||||
for (i = 0; i < request->num_accept_types; i++) heap_free( request->accept_types[i] );
|
|
||||||
heap_free( request->accept_types );
|
|
||||||
for (i = 0; i < TARGET_MAX; i++)
|
for (i = 0; i < TARGET_MAX; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < SCHEME_MAX; j++)
|
for (j = 0; j < SCHEME_MAX; j++)
|
||||||
|
@ -1042,34 +1040,15 @@ static const struct object_vtbl request_vtbl =
|
||||||
request_set_option
|
request_set_option
|
||||||
};
|
};
|
||||||
|
|
||||||
static BOOL store_accept_types( struct request *request, const WCHAR **accept_types )
|
static BOOL add_accept_types_header( struct request *request, const WCHAR **types )
|
||||||
{
|
{
|
||||||
const WCHAR **types = accept_types;
|
static const WCHAR acceptW[] = {'A','c','c','e','p','t',0};
|
||||||
DWORD i;
|
static const DWORD flags = WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
|
||||||
|
|
||||||
if (!types) return TRUE;
|
if (!types) return TRUE;
|
||||||
while (*types)
|
while (*types)
|
||||||
{
|
{
|
||||||
request->num_accept_types++;
|
if (!process_header( request, acceptW, *types, flags, TRUE )) return FALSE;
|
||||||
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 - 1] );
|
|
||||||
heap_free( request->accept_types );
|
|
||||||
request->accept_types = NULL;
|
|
||||||
request->num_accept_types = 0;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
types++;
|
types++;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1151,7 +1130,7 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
|
||||||
|
|
||||||
if (!version || !version[0]) version = http1_1;
|
if (!version || !version[0]) version = http1_1;
|
||||||
if (!(request->version = strdupW( version ))) goto end;
|
if (!(request->version = strdupW( version ))) goto end;
|
||||||
if (!(store_accept_types( request, types ))) goto end;
|
if (!(add_accept_types_header( request, types ))) goto end;
|
||||||
|
|
||||||
if (!(hrequest = alloc_handle( &request->hdr ))) goto end;
|
if (!(hrequest = alloc_handle( &request->hdr ))) goto end;
|
||||||
request->hdr.handle = hrequest;
|
request->hdr.handle = hrequest;
|
||||||
|
|
|
@ -198,8 +198,6 @@ struct request
|
||||||
char read_buf[8192]; /* buffer for already read but not returned data */
|
char read_buf[8192]; /* buffer for already read but not returned data */
|
||||||
struct header *headers;
|
struct header *headers;
|
||||||
DWORD num_headers;
|
DWORD num_headers;
|
||||||
WCHAR **accept_types;
|
|
||||||
DWORD num_accept_types;
|
|
||||||
struct authinfo *authinfo;
|
struct authinfo *authinfo;
|
||||||
struct authinfo *proxy_authinfo;
|
struct authinfo *proxy_authinfo;
|
||||||
HANDLE task_wait;
|
HANDLE task_wait;
|
||||||
|
@ -288,7 +286,8 @@ void destroy_cookies( struct session * ) DECLSPEC_HIDDEN;
|
||||||
BOOL set_server_for_hostname( struct connect *, const WCHAR *, INTERNET_PORT ) DECLSPEC_HIDDEN;
|
BOOL set_server_for_hostname( struct connect *, const WCHAR *, INTERNET_PORT ) DECLSPEC_HIDDEN;
|
||||||
void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
|
void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
void release_host( struct hostdata *host ) DECLSPEC_HIDDEN;
|
void release_host( struct hostdata * ) DECLSPEC_HIDDEN;
|
||||||
|
BOOL process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
|
extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
|
||||||
void release_typelib( void ) DECLSPEC_HIDDEN;
|
void release_typelib( void ) DECLSPEC_HIDDEN;
|
||||||
|
|
Loading…
Reference in New Issue