[4/9] winhttp: Move handling of default request parameters into build_request_string().
Hans Leidekker
hans at codeweavers.com
Wed Sep 3 05:30:44 CDT 2008
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index b0b81f0..66d2abd 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -458,17 +458,25 @@ BOOL WINAPI WinHttpAddRequestHeaders( HINTERNET hrequest, LPCWSTR headers, DWORD
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 crlf[] = {'\r','\n',0};
static const WCHAR colon[] = {':',' ',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;
const WCHAR **headers, **p;
+ const WCHAR *verb = get, *path = slash, *version = http1_1;
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 */
len = request->num_headers * 4 + 7;
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
DWORD len;
if (request_only)
- headers = build_request_string( request, request->verb, request->path, request->version );
+ headers = build_request_string( request );
else
headers = request->raw_headers;
@@ -752,7 +760,7 @@ static BOOL send_request( request_t *request, LPCWSTR headers, DWORD headers_len
}
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;
TRACE("full request: %s\n", debugstr_a(req_ascii));
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index 9b66dcc..885a4a4 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -232,10 +232,6 @@ static const object_vtbl_t request_vtbl =
HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version,
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;
connect_t *connect;
HINTERNET hrequest = NULL;
@@ -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 (!verb || !*verb) verb = get;
- if (!object || !*object) object = slash;
- if (!version || !*version) version = http1_1;
-
- if (!(request->verb = strdupW( verb ))) goto end;
- if (!(request->path = strdupW( object ))) goto end;
- if (!(request->version = strdupW( version ))) goto end;
+ if (verb && !(request->verb = strdupW( verb ))) goto end;
+ if (object && !(request->path = strdupW( object ))) goto end;
+ if (version && !(request->version = strdupW( version ))) goto end;
if (!(hrequest = alloc_handle( &request->hdr ))) goto end;
request->hdr.handle = hrequest;
More information about the wine-patches
mailing list