Simplify HTTP_InsertProxyAuthorization.

This commit is contained in:
Robert Shearman 2005-11-28 11:17:06 +01:00 committed by Alexandre Julliard
parent b9d7754034
commit 22edb3e99e
1 changed files with 9 additions and 19 deletions

View File

@ -873,30 +873,20 @@ static LPWSTR HTTP_EncodeBasicAuth( LPCWSTR username, LPCWSTR password)
static BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr, static BOOL HTTP_InsertProxyAuthorization( LPWININETHTTPREQW lpwhr,
LPCWSTR username, LPCWSTR password ) LPCWSTR username, LPCWSTR password )
{ {
HTTPHEADERW hdr; WCHAR *authorization = HTTP_EncodeBasicAuth( username, password );
INT index; BOOL ret;
static const WCHAR szProxyAuthorization[] = {
'P','r','o','x','y','-','A','u','t','h','o','r','i','z','a','t','i','o','n',0 };
hdr.lpszValue = HTTP_EncodeBasicAuth( username, password ); if (!authorization)
hdr.lpszField = (WCHAR *)szProxyAuthorization;
hdr.wFlags = HDR_ISREQUEST;
hdr.wCount = 0;
if( !hdr.lpszValue )
return FALSE; return FALSE;
TRACE("Inserting %s = %s\n", TRACE( "Inserting authorization: %s\n", debugstr_w( authorization ) );
debugstr_w( hdr.lpszField ), debugstr_w( hdr.lpszValue ) );
/* remove the old proxy authorization header */ ret = HTTP_ReplaceHeaderValue( &lpwhr->StdHeaders[HTTP_QUERY_PROXY_AUTHORIZATION],
index = HTTP_GetCustomHeaderIndex( lpwhr, hdr.lpszField ); authorization );
if( index >=0 )
HTTP_DeleteCustomHeader( lpwhr, index );
HTTP_InsertCustomHeader(lpwhr, &hdr); HeapFree( GetProcessHeap(), 0, authorization );
HeapFree( GetProcessHeap(), 0, hdr.lpszValue );
return TRUE; return ret;
} }
/*********************************************************************** /***********************************************************************