Commit 8063f5cb authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

winhttp: Move handling of default request parameters into build_request_string().

parent 9f8d4fe0
...@@ -458,17 +458,25 @@ BOOL WINAPI WinHttpAddRequestHeaders( HINTERNET hrequest, LPCWSTR headers, DWORD ...@@ -458,17 +458,25 @@ BOOL WINAPI WinHttpAddRequestHeaders( HINTERNET hrequest, LPCWSTR headers, DWORD
return ret; return ret;
} }
static WCHAR *build_request_string( request_t *request, LPCWSTR verb, LPCWSTR path, LPCWSTR version ) static WCHAR *build_request_string( request_t *request )
{ {
static const WCHAR space[] = {' ',0}; static const WCHAR space[] = {' ',0};
static const WCHAR crlf[] = {'\r','\n',0}; static const WCHAR crlf[] = {'\r','\n',0};
static const WCHAR colon[] = {':',' ',0}; static const WCHAR colon[] = {':',' ',0};
static const WCHAR twocrlf[] = {'\r','\n','\r','\n',0}; static const WCHAR twocrlf[] = {'\r','\n','\r','\n',0};
static const WCHAR get[] = {'G','E','T',0};
static const WCHAR slash[] = {'/',0};
static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0};
WCHAR *ret; WCHAR *ret;
const WCHAR **headers, **p; const WCHAR **headers, **p;
const WCHAR *verb = get, *path = slash, *version = http1_1;
unsigned int len, i = 0, j; unsigned int len, i = 0, j;
if (request->verb && request->verb[0]) verb = request->verb;
if (request->path && request->path[0]) path = request->path;
if (request->version && request->version[0]) version = request->version;
/* 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 = request->num_headers * 4 + 7; len = request->num_headers * 4 + 7;
if (!(headers = heap_alloc( len * sizeof(LPCWSTR) ))) return NULL; if (!(headers = heap_alloc( len * sizeof(LPCWSTR) ))) return NULL;
...@@ -537,7 +545,7 @@ static BOOL query_headers( request_t *request, DWORD level, LPCWSTR name, LPVOID ...@@ -537,7 +545,7 @@ static BOOL query_headers( request_t *request, DWORD level, LPCWSTR name, LPVOID
DWORD len; DWORD len;
if (request_only) if (request_only)
headers = build_request_string( request, request->verb, request->path, request->version ); headers = build_request_string( request );
else else
headers = request->raw_headers; headers = request->raw_headers;
...@@ -752,7 +760,7 @@ static BOOL send_request( request_t *request, LPCWSTR headers, DWORD headers_len ...@@ -752,7 +760,7 @@ static BOOL send_request( request_t *request, LPCWSTR headers, DWORD headers_len
} }
if (!(ret = open_connection( request ))) goto end; if (!(ret = open_connection( request ))) goto end;
if (!(req = build_request_string( request, request->verb, request->path, request->version ))) goto end; if (!(req = build_request_string( request ))) goto end;
if (!(req_ascii = strdupWA( req ))) goto end; if (!(req_ascii = strdupWA( req ))) goto end;
TRACE("full request: %s\n", debugstr_a(req_ascii)); TRACE("full request: %s\n", debugstr_a(req_ascii));
......
...@@ -232,10 +232,6 @@ static const object_vtbl_t request_vtbl = ...@@ -232,10 +232,6 @@ static const object_vtbl_t request_vtbl =
HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version,
LPCWSTR referrer, LPCWSTR *types, DWORD flags ) LPCWSTR referrer, LPCWSTR *types, DWORD flags )
{ {
static const WCHAR get[] = {'G','E','T',0};
static const WCHAR slash[] = {'/',0};
static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0};
request_t *request; request_t *request;
connect_t *connect; connect_t *connect;
HINTERNET hrequest = NULL; HINTERNET hrequest = NULL;
...@@ -272,13 +268,9 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o ...@@ -272,13 +268,9 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
if (!netconn_init( &request->netconn, request->hdr.flags & WINHTTP_FLAG_SECURE )) goto end; if (!netconn_init( &request->netconn, request->hdr.flags & WINHTTP_FLAG_SECURE )) goto end;
if (!verb || !*verb) verb = get; if (verb && !(request->verb = strdupW( verb ))) goto end;
if (!object || !*object) object = slash; if (object && !(request->path = strdupW( object ))) goto end;
if (!version || !*version) version = http1_1; if (version && !(request->version = strdupW( version ))) goto end;
if (!(request->verb = strdupW( verb ))) goto end;
if (!(request->path = strdupW( object ))) goto end;
if (!(request->version = strdupW( version ))) 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;
......
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