50#define NO_SHLWAPI_STREAM
67#define HTTP_ADDHDR_FLAG_ADD 0x20000000
68#define HTTP_ADDHDR_FLAG_ADD_IF_NEW 0x10000000
69#define HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA 0x40000000
70#define HTTP_ADDHDR_FLAG_COALESCE_WITH_SEMICOLON 0x01000000
71#define HTTP_ADDHDR_FLAG_REPLACE 0x80000000
72#define HTTP_ADDHDR_FLAG_REQ 0x02000000
74#define COLLECT_TIME 60000
122 0, 0, { (
DWORD_PTR)(__FILE__
": authcache_cs") }
142 0, 0, { (
DWORD_PTR)(__FILE__
": connection_pool_cs") }
177 size_t name_len,
len;
213 if(!
server && do_create) {
218 server->is_https = is_https;
271 BOOL remaining_conns;
284 }
while(remaining_conns);
298 if (HeaderIndex == -1)
338 CHUNKED_STREAM_STATE_ERROR
386 DWORD current_read, ret_read = 0;
390 TRACE(
"(%d %x)\n",
size, allow_blocking);
400 sizeof(gzip_stream->
buf)-gzip_stream->
buf_size, ¤t_read, allow_blocking);
404 gzip_stream->
buf_size += current_read;
406 WARN(
"unexpected end of data\n");
418 size -= current_read;
419 ret_read += current_read;
423 TRACE(
"end of data\n");
426 }
else if(zres !=
Z_OK) {
434 allow_blocking =
FALSE;
437 TRACE(
"read %u bytes\n", ret_read);
493 ERR(
"inflateInit failed: %d\n", zres);
590 req[
n++] =
request->custHeaders[
i].lpszField;
592 req[
n++] =
request->custHeaders[
i].lpszValue;
597 TRACE(
"Adding custom header %s (%s)\n",
610 return requestString;
643 req[
n++] =
request->custHeaders[
i].lpszField;
645 req[
n++] =
request->custHeaders[
i].lpszValue;
650 TRACE(
"Adding custom header %s (%s)\n",
681 if (tmp && tmp[1]) tmp[1] = 0;
690 setCookieHeader = &
request->custHeaders[HeaderIndex];
729 static const WCHAR szBasic[] = {
'B',
'a',
's',
'i',
'c'};
730 static const WCHAR szRealm[] = {
'r',
'e',
'a',
'l',
'm'};
734 if (is_basic && pszRealm)
745 while (*realm ==
' ')
751 while (*
token ==
' ')
792 TRACE(
"Authorization found in cache\n");
834 TRACE(
"Found match in cache, replacing\n");
849 TRACE(
"authorization cached\n");
864 TRACE(
"Authorization found in cache\n");
869 if(!nt_auth_identity->
User || !nt_auth_identity->
Password ||
1024 if (domain_and_username)
1031 pAuthData = &nt_auth_identity;
1036 user = domain_and_username;
1051 pAuthData = &nt_auth_identity;
1062 if(pAuthData && !domain_and_username) {
1080 WARN(
"AcquireCredentialsHandleW for scheme %s failed with error 0x%08x\n",
1087 *ppAuthInfo = pAuthInfo;
1095 ERR(
"authentication scheme changed from %s to %s\n",
1109 if (!domain_and_username)
1111 if (
host && szRealm)
1136 if (
host && szRealm)
1161 in_desc.pBuffers = &
in;
1164 if (*pszAuthData ==
' ')
1180 out_desc.pBuffers = &
out;
1186 in.pvBuffer ? &in_desc :
NULL,
1187 0, &pAuthInfo->
ctx, &out_desc,
1188 &pAuthInfo->
attr, &pAuthInfo->
exp);
1194 TRACE(
"sending last auth packet\n");
1200 TRACE(
"sending next auth packet\n");
1204 ERR(
"InitializeSecurityContextW returned error 0x%08x\n", sec_status);
1228 if( dwHeaderLength == ~0
U )
1231 len = dwHeaderLength;
1241 lpszEnd = lpszStart;
1243 while (*lpszEnd !=
'\0')
1245 if (*lpszEnd ==
'\r' || *lpszEnd ==
'\n')
1250 if (*lpszStart ==
'\0')
1253 if (*lpszEnd ==
'\r' || *lpszEnd ==
'\n')
1259 if (*lpszStart ==
'\0')
1262 lpszStart = lpszEnd;
1274 lpszStart = lpszEnd;
1303 TRACE(
"%p, %s, %u, %08x\n", hHttpRequest,
debugstr_wn(lpszHeader, dwHeaderLength), dwHeaderLength, dwModifier);
1335 TRACE(
"%p, %s, %u, %08x\n", hHttpRequest,
debugstr_an(lpszHeader, dwHeaderLength), dwHeaderLength, dwModifier);
1362 const char **
types = accept_types;
1381 WARN(
"invalid accept type pointer\n");
1382 invalid_pointer =
TRUE;
1387 if (invalid_pointer)
return NULL;
1390 types = accept_types;
1419 TRACE(
"(%p, %s, %s, %s, %s, %p, %08x, %08lx)\n", hHttpSession,
1434 if ( !szObjectName )
1471 static const CHAR HTTP_Base64Enc[] =
1472 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1477 base64[
n++] = HTTP_Base64Enc[(
bin[0] & 0xfc) >> 2];
1478 x = (
bin[0] & 3) << 4;
1483 base64[
n++] = HTTP_Base64Enc[
x];
1488 base64[
n++] = HTTP_Base64Enc[
x | ( (
bin[1]&0xf0) >> 4 ) ];
1489 x = (
bin[1] & 0x0f ) << 2;
1494 base64[
n++] = HTTP_Base64Enc[
x];
1498 base64[
n++] = HTTP_Base64Enc[
x | ( (
bin[2]&0xc0 ) >> 6 ) ];
1501 base64[
n++] = HTTP_Base64Enc[
bin[2] & 0x3f ];
1511 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1512 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1513 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
1514 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
1515 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1516 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
1517 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
1518 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
1544 if ((base64[2] ==
'=') && (base64[3] ==
'='))
1556 if (base64[3] ==
'=')
1565 bin[
n] = (
unsigned char) (((
in[2] << 6) & 0xc0) |
in[3]);
1580 len = scheme_len + 1 + ((data_len + 2) * 4) / 3;
1583 ret[scheme_len] =
' ';
1664 if(*req->
path !=
'/')
1671 if(*req->
path !=
'/')
1717 return *(
ptr - 1) ==
'.';
1750 static WCHAR szNul[] =
L"";
1802 addr_len =
sizeof(
server->addr);
1806 server->addr_len = addr_len;
1837 if(req->
path[0] !=
'/')
1867 request->headers_section.DebugInfo->Spare[0] = 0;
1869 request->read_section.DebugInfo->Spare[0] = 0;
1954 WCHAR szConnectionResponse[20];
1966 dwBufferSize =
sizeof(szConnectionResponse);
1970 keepalive = !
wcsicmp(szConnectionResponse,
L"Keep-Alive");
2037 if(
info->lpszSubjectInfo)
2044 if(
info->lpszIssuerInfo)
2063 FIXME(
"INTERNET_DIAGNOSTIC_SOCKET_INFO stub\n");
2073 info->SourcePort = 0;
2087 TRACE(
"Queried undocumented option 98, forwarding to INTERNET_OPTION_SECURITY_FLAGS\n");
2100 TRACE(
"INTERNET_OPTION_SECURITY_FLAGS %x\n",
flags);
2105 TRACE(
"INTERNET_OPTION_HANDLE_TYPE\n");
2118 TRACE(
"INTERNET_OPTION_URL\n");
2145 TRACE(
"INTERNET_OPTION_CACHE_TIMESTAMPS\n");
2150 if (*
size <
sizeof(*ts))
2152 *
size =
sizeof(*ts);
2170 *
size =
sizeof(*ts);
2179 TRACE(
"INTERNET_OPTION_DATAFILE_NAME\n");
2188 if(*
size < req_size)
2196 if (req_size > *
size)
2222 char expiration[64];
2225 char encryption[64];
2229 char start_date[32];
2230 char start_time[32];
2231 char expiry_date[32];
2232 char expiry_time[32];
2261 strength,
sizeof(strength));
2279 subject,
info.lpszSubjectInfo,
2281 effective, start_date, start_time,
2282 expiration, expiry_date, expiry_time,
2284 privacy, strength,
info.dwKeySize,
bits);
2286 if(needed < *
size) {
2297 subject,
info.lpszSubjectInfo,
2299 effective, start_date, start_time,
2300 expiration, expiry_date, expiry_time,
2302 privacy, strength,
info.dwKeySize,
bits);
2338 TRACE(
"INTERNET_OPTION_REQUEST_FLAGS returning %x\n",
flags);
2345 TRACE(
"INTERNET_OPTION_ERROR_MASK\n");
2364 TRACE(
"Undocumented option 99\n");
2379 TRACE(
"INTERNET_OPTION_SECURITY_FLAGS %08x\n",
flags);
2474 if(header_idx != -1) {
2480 while(*
ptr==
' ' || *
ptr==
'\t')
2506 FIXME(
"INTERNET_FLAG_NEED_FILE is not supported correctly\n");
2511 WARN(
"Could not get URL\n");
2558 if (maxlen == -1) maxlen =
sizeof(req->
read_buf);
2588 bytes_read =
count + 1;
2600 WARN(
"read failed %u\n",
res );
2607 TRACE(
"returning empty string\n" );
2671 &
read, allow_blocking);
2758 switch(chunked_stream->
state) {
2759 case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END:
2760 case CHUNKED_STREAM_STATE_END_OF_STREAM:
2761 case CHUNKED_STREAM_STATE_ERROR:
2782 BOOL blocking_read = allow_blocking;
2784 switch(chunked_stream->
state) {
2785 case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END:
2786 case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE:
2789 blocking_read =
FALSE;
2791 case CHUNKED_STREAM_STATE_READING_CHUNK_SIZE:
2792 case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA:
2798 if(ret_read || allow_blocking)
2800 continue_read =
FALSE;
2803 chunked_stream->
state = CHUNKED_STREAM_STATE_ERROR;
2811 switch(chunked_stream->
state) {
2812 case CHUNKED_STREAM_STATE_READING_CHUNK_SIZE:
2815 if(ch >=
'0' && ch <=
'9') {
2817 }
else if(ch >=
'a' && ch <=
'f') {
2819 }
else if (ch >=
'A' && ch <=
'F') {
2821 }
else if (ch ==
';' || ch ==
'\r' || ch ==
'\n') {
2827 chunked_stream->
state = CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE;
2831 case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE:
2835 ? CHUNKED_STREAM_STATE_READING_CHUNK
2836 : CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END;
2838 WARN(
"unexpected char '%c'\n", ch);
2841 case CHUNKED_STREAM_STATE_READING_CHUNK:
2844 continue_read =
FALSE;
2860 continue_read =
FALSE;
2865 chunked_stream->
state = CHUNKED_STREAM_STATE_ERROR;
2874 chunked_stream->
state = CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA;
2875 allow_blocking =
FALSE;
2878 case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA:
2881 chunked_stream->
state = CHUNKED_STREAM_STATE_READING_CHUNK_SIZE;
2883 WARN(
"unexpected char '%c'\n", ch);
2886 case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END:
2889 chunked_stream->
state = CHUNKED_STREAM_STATE_END_OF_STREAM;
2891 WARN(
"unexpected char '%c'\n", ch);
2894 case CHUNKED_STREAM_STATE_END_OF_STREAM:
2895 case CHUNKED_STREAM_STATE_ERROR:
2896 continue_read =
FALSE;
2899 }
while(continue_read);
2906 TRACE(
"read %d bytes\n", ret_read);
2917 while(chunked_stream->
state != CHUNKED_STREAM_STATE_END_OF_STREAM
2918 && chunked_stream->
state != CHUNKED_STREAM_STATE_ERROR) {
2924 if(chunked_stream->
state != CHUNKED_STREAM_STATE_END_OF_STREAM)
2945 WCHAR contentLength[32];
2954 size =
sizeof(contentLength);
2970 chunked_stream =
heap_alloc(
sizeof(*chunked_stream));
2977 chunked_stream->
state = CHUNKED_STREAM_STATE_READING_CHUNK_SIZE;
2995 if(encoding_idx != -1) {
3001 if(!
wcsicmp(
request->custHeaders[encoding_idx].lpszValue,
L"deflate")) {
3040 WARN(
"res %u read %u, closing connection\n",
res,
read);
3055 DWORD current_read = 0, ret_read = 0;
3065 allow_blocking =
FALSE;
3068 if(ret_read <
size) {
3071 ret_read += current_read;
3079 TRACE(
"retrieved %u bytes (res %u)\n", ret_read,
res );
3127 while (read < task->
size) {
3139 complete_arg =
read;
3179 BOOL allow_blocking, notify_received =
FALSE;
3207 notify_received =
TRUE;
3255 request->bytesWritten += *written;
3265 BOOL allow_blocking, notify_received =
FALSE;
3289 notify_received =
TRUE;
3321 TRACE(
"(%p)\n", req);
3324 WARN(
"No cache file name available\n");
3382 request->headers_section.DebugInfo->Spare[0] = (
DWORD_PTR)(__FILE__
": http_request_t.headers_section");
3385 request->read_section.DebugInfo->Spare[0] = (
DWORD_PTR)(__FILE__
": http_request_t.read_section");
3407 if (lpszObjectName && *lpszObjectName) {
3420 ERR(
"Unable to escape string!(%s) (%d)\n",
debugstr_w(lpszObjectName),rc);
3427 if (lpszReferrer && *lpszReferrer)
3430 if (lpszAcceptTypes)
3433 for (
i = 0; lpszAcceptTypes[
i];
i++)
3435 if (!*lpszAcceptTypes[
i])
continue;
3478 TRACE(
"(%p, %s, %s, %s, %s, %p, %08x, %08lx)\n", hHttpSession,
3482 if(lpszAcceptTypes!=
NULL)
3485 for(
i=0;lpszAcceptTypes[
i]!=
NULL;
i++)
3504 lpszVersion, lpszReferrer, lpszAcceptTypes,
3518 L"Content-Transfer-Encoding",
3522 L"Content-Language",
3545 L"Content-Encoding",
3548 L"If-Modified-Since",
3556 L"WWW-Authenticate",
3557 L"Proxy-Authenticate",
3563 L"Content-Disposition",
3567 L"Content-Location",
3575 L"If-Unmodified-Since",
3577 L"Proxy-Authorization",
3579 L"Transfer-Encoding",
3585 L"Proxy-Connection",
3586 L"Unless-Modified-Since",
3597 INT requested_index = lpdwIndex ? *lpdwIndex : 0;