winhttp: Implement some more options.

This commit is contained in:
Hans Leidekker 2008-09-03 16:58:06 +02:00 committed by Alexandre Julliard
parent c614a2481a
commit e078f618eb
4 changed files with 80 additions and 6 deletions

View File

@ -768,7 +768,7 @@ static BOOL send_request( request_t *request, LPCWSTR headers, DWORD headers_len
sprintfW( length, length_fmt, total_len );
process_header( request, attr_content_length, length, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE );
}
if (!(request->hdr.flags & WINHTTP_DISABLE_KEEP_ALIVE))
if (!(request->hdr.disable_flags & WINHTTP_DISABLE_KEEP_ALIVE))
{
process_header( request, attr_connection, keep_alive, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE );
}
@ -1097,7 +1097,7 @@ BOOL WINAPI WinHttpReceiveResponse( HINTERNET hrequest, LPVOID reserved )
if (status == 200) break;
if (status == 301 || status == 302)
{
if (request->hdr.flags & WINHTTP_DISABLE_REDIRECTS) break;
if (request->hdr.disable_flags & WINHTTP_DISABLE_REDIRECTS) break;
drain_content( request );
if (!(ret = handle_redirect( request ))) break;
}

View File

@ -69,11 +69,36 @@ static void session_destroy( object_header_t *hdr )
heap_free( session );
}
static BOOL session_set_option( object_header_t *hdr, DWORD option, LPVOID buffer, DWORD buflen )
{
switch (option)
{
case WINHTTP_OPTION_PROXY:
{
WINHTTP_PROXY_INFO *pi = buffer;
FIXME("%u %s %s\n", pi->dwAccessType, debugstr_w(pi->lpszProxy), debugstr_w(pi->lpszProxyBypass));
return TRUE;
}
case WINHTTP_OPTION_REDIRECT_POLICY:
{
DWORD policy = *(DWORD *)buffer;
TRACE("0x%x\n", policy);
hdr->redirect_policy = policy;
return TRUE;
}
default:
FIXME("unimplemented option %u\n", option);
return TRUE;
}
}
static const object_vtbl_t session_vtbl =
{
session_destroy,
NULL,
NULL
session_set_option
};
/***********************************************************************
@ -220,11 +245,52 @@ static void request_destroy( object_header_t *hdr )
heap_free( request );
}
static BOOL request_set_option( object_header_t *hdr, DWORD option, LPVOID buffer, DWORD buflen )
{
switch (option)
{
case WINHTTP_OPTION_PROXY:
{
WINHTTP_PROXY_INFO *pi = buffer;
FIXME("%u %s %s\n", pi->dwAccessType, debugstr_w(pi->lpszProxy), debugstr_w(pi->lpszProxyBypass));
return TRUE;
}
case WINHTTP_OPTION_DISABLE_FEATURE:
{
DWORD disable = *(DWORD *)buffer;
TRACE("0x%x\n", disable);
hdr->disable_flags &= disable;
return TRUE;
}
case WINHTTP_OPTION_AUTOLOGON_POLICY:
{
DWORD policy = *(DWORD *)buffer;
TRACE("0x%x\n", policy);
hdr->logon_policy = policy;
return TRUE;
}
case WINHTTP_OPTION_REDIRECT_POLICY:
{
DWORD policy = *(DWORD *)buffer;
TRACE("0x%x\n", policy);
hdr->redirect_policy = policy;
return TRUE;
}
default:
FIXME("unimplemented option %u\n", option);
return TRUE;
}
}
static const object_vtbl_t request_vtbl =
{
request_destroy,
NULL,
NULL
request_set_option
};
/***********************************************************************
@ -350,7 +416,7 @@ BOOL WINAPI WinHttpQueryOption( HINTERNET handle, DWORD option, LPVOID buffer, L
static BOOL set_option( object_header_t *hdr, DWORD option, LPVOID buffer, DWORD buflen )
{
BOOL ret = FALSE;
BOOL ret = TRUE;
switch (option)
{

View File

@ -532,12 +532,16 @@ static void test_secure_connection(void)
static const WCHAR google[] = {'w','w','w','.','g','o','o','g','l','e','.','c','o','m',0};
HANDLE ses, con, req;
DWORD size, status;
DWORD size, status, policy;
BOOL ret;
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
policy = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS;
ret = WinHttpSetOption(ses, WINHTTP_OPTION_REDIRECT_POLICY, &policy, sizeof(policy));
ok(ret, "failed to set redirect policy %u\n", GetLastError());
con = WinHttpConnect(ses, google, 443, 0);
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
@ -569,6 +573,7 @@ static void test_secure_connection(void)
size = sizeof(status);
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL);
ok(ret, "failed unexpectedly %u\n", GetLastError());
ok(status == 200, "request failed unexpectedly %u\n", status);
size = 0;
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, NULL, &size, NULL);

View File

@ -51,6 +51,9 @@ struct _object_header_t
HINTERNET handle;
const object_vtbl_t *vtbl;
DWORD flags;
DWORD disable_flags;
DWORD logon_policy;
DWORD redirect_policy;
DWORD error;
DWORD_PTR context;
LONG refs;