How I improved wininet for SSL through a proxy...

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
wolbrink
Level 1
Level 1
Posts: 6
Joined: Wed Jun 02, 2010 7:59 pm

How I improved wininet for SSL through a proxy...

Post by wolbrink »

I'm trying to get my app to use WinInet to connect to a https url through a proxy. I found that the following patch (my code in bold) to http.c improved wininet.dll.so (based on the 2.1-rc2 code) so that my app can talk to some servers. It still doesn't work if the server returns with a CONTINUE. But not all servers are using this. Thankfully the one server my app really depends on doesn't use CONTINUE, so this is a big step forward for me.

Here it is (the original logic I'm enhancing is in blue):

static LPWSTR HTTP_BuildHeaderRequestString( http_request_t *lpwhr, LPCWSTR verb, LPCWSTR path, LPCWSTR version )
{

...
static const WCHAR szZero[] = { '0',0 };
static const WCHAR szConnect[] = {'C','O','N','N','E','C','T',0};
...
if (!strcmpW(szContent_Length, lpwhr->pCustHeaders.lpszField) && !strcmpW(verb, szConnect))
{
// CONNECT ... Content-Length: 0 <-- seems to help POST over SSL w/ Proxy
req[n++] = szCrLf;
req[n++] = lpwhr->pCustHeaders.lpszField;
req[n++] = szColon;
req[n++] = szZero;

TRACE("Adding custom header %s (%s)\n",
debugstr_w(lpwhr->pCustHeaders.lpszField),
debugstr_w(szZero));
}
else {
req[n++] = szCrLf;
req[n++] = lpwhr->pCustHeaders.lpszField;
req[n++] = szColon;
req[n++] = lpwhr->pCustHeaders.lpszValue;

TRACE("Adding custom header %s (%s)\n",
debugstr_w(lpwhr->pCustHeaders.lpszField),
debugstr_w(lpwhr->pCustHeaders.lpszValue));
}
...
}


// It's changing the Content-Length header to always be "Content-Length: 0" when the "CONNECT" method is used
Locked