Commit 7f5e2732 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

wininet: Use a lookup table sorted by index so we don't need a loop to do lookups.

parent ae300883
...@@ -1163,12 +1163,6 @@ lend: ...@@ -1163,12 +1163,6 @@ lend:
return handle; return handle;
} }
typedef struct std_hdr_data
{
const WCHAR* hdrStr;
INT hdrIndex;
} std_hdr_data;
static const WCHAR szAccept[] = { 'A','c','c','e','p','t',0 }; static const WCHAR szAccept[] = { 'A','c','c','e','p','t',0 };
static const WCHAR szAccept_Charset[] = { 'A','c','c','e','p','t','-','C','h','a','r','s','e','t', 0 }; static const WCHAR szAccept_Charset[] = { 'A','c','c','e','p','t','-','C','h','a','r','s','e','t', 0 };
static const WCHAR szAccept_Encoding[] = { 'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0 }; static const WCHAR szAccept_Encoding[] = { 'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0 };
...@@ -1223,65 +1217,82 @@ static const WCHAR szVia[] = { 'V','i','a',0 }; ...@@ -1223,65 +1217,82 @@ static const WCHAR szVia[] = { 'V','i','a',0 };
static const WCHAR szWarning[] = { 'W','a','r','n','i','n','g',0 }; static const WCHAR szWarning[] = { 'W','a','r','n','i','n','g',0 };
static const WCHAR szWWW_Authenticate[] = { 'W','W','W','-','A','u','t','h','e','n','t','i','c','a','t','e',0 }; static const WCHAR szWWW_Authenticate[] = { 'W','W','W','-','A','u','t','h','e','n','t','i','c','a','t','e',0 };
static const std_hdr_data SORTED_STANDARD_HEADERS[] = { static const LPCWSTR header_lookup[] = {
{szAccept, HTTP_QUERY_ACCEPT,}, szMime_Version, /* HTTP_QUERY_MIME_VERSION = 0 */
{szAccept_Charset, HTTP_QUERY_ACCEPT_CHARSET,}, szContent_Type, /* HTTP_QUERY_CONTENT_TYPE = 1 */
{szAccept_Encoding, HTTP_QUERY_ACCEPT_ENCODING,}, szContent_Transfer_Encoding,/* HTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2 */
{szAccept_Language, HTTP_QUERY_ACCEPT_LANGUAGE,}, szContent_ID, /* HTTP_QUERY_CONTENT_ID = 3 */
{szAccept_Ranges, HTTP_QUERY_ACCEPT_RANGES,}, NULL, /* HTTP_QUERY_CONTENT_DESCRIPTION = 4 */
{szAge, HTTP_QUERY_AGE,}, szContent_Length, /* HTTP_QUERY_CONTENT_LENGTH = 5 */
{szAllow, HTTP_QUERY_ALLOW,}, szContent_Language, /* HTTP_QUERY_CONTENT_LANGUAGE = 6 */
{szAuthorization, HTTP_QUERY_AUTHORIZATION,}, szAllow, /* HTTP_QUERY_ALLOW = 7 */
{szCache_Control, HTTP_QUERY_CACHE_CONTROL,}, szPublic, /* HTTP_QUERY_PUBLIC = 8 */
{szConnection, HTTP_QUERY_CONNECTION,}, szDate, /* HTTP_QUERY_DATE = 9 */
{szContent_Base, HTTP_QUERY_CONTENT_BASE,}, szExpires, /* HTTP_QUERY_EXPIRES = 10 */
{szContent_Encoding, HTTP_QUERY_CONTENT_ENCODING,}, szLast_Modified, /* HTTP_QUERY_LAST_MODIFIED = 11 */
{szContent_ID, HTTP_QUERY_CONTENT_ID,}, NULL, /* HTTP_QUERY_MESSAGE_ID = 12 */
{szContent_Language, HTTP_QUERY_CONTENT_LANGUAGE,}, szURI, /* HTTP_QUERY_URI = 13 */
{szContent_Length, HTTP_QUERY_CONTENT_LENGTH,}, szFrom, /* HTTP_QUERY_DERIVED_FROM = 14 */
{szContent_Location, HTTP_QUERY_CONTENT_LOCATION,}, NULL, /* HTTP_QUERY_COST = 15 */
{szContent_MD5, HTTP_QUERY_CONTENT_MD5,}, NULL, /* HTTP_QUERY_LINK = 16 */
{szContent_Range, HTTP_QUERY_CONTENT_RANGE,}, szPragma, /* HTTP_QUERY_PRAGMA = 17 */
{szContent_Transfer_Encoding,HTTP_QUERY_CONTENT_TRANSFER_ENCODING,}, NULL, /* HTTP_QUERY_VERSION = 18 */
{szContent_Type, HTTP_QUERY_CONTENT_TYPE,}, szStatus, /* HTTP_QUERY_STATUS_CODE = 19 */
{szCookie, HTTP_QUERY_COOKIE,}, NULL, /* HTTP_QUERY_STATUS_TEXT = 20 */
{szDate, HTTP_QUERY_DATE,}, NULL, /* HTTP_QUERY_RAW_HEADERS = 21 */
{szETag, HTTP_QUERY_ETAG,}, NULL, /* HTTP_QUERY_RAW_HEADERS_CRLF = 22 */
{szExpect, HTTP_QUERY_EXPECT,}, szConnection, /* HTTP_QUERY_CONNECTION = 23 */
{szExpires, HTTP_QUERY_EXPIRES,}, szAccept, /* HTTP_QUERY_ACCEPT = 24 */
{szFrom, HTTP_QUERY_DERIVED_FROM,}, szAccept_Charset, /* HTTP_QUERY_ACCEPT_CHARSET = 25 */
{szHost, HTTP_QUERY_HOST,}, szAccept_Encoding, /* HTTP_QUERY_ACCEPT_ENCODING = 26 */
{szIf_Match, HTTP_QUERY_IF_MATCH,}, szAccept_Language, /* HTTP_QUERY_ACCEPT_LANGUAGE = 27 */
{szIf_Modified_Since, HTTP_QUERY_IF_MODIFIED_SINCE,}, szAuthorization, /* HTTP_QUERY_AUTHORIZATION = 28 */
{szIf_None_Match, HTTP_QUERY_IF_NONE_MATCH,}, szContent_Encoding, /* HTTP_QUERY_CONTENT_ENCODING = 29 */
{szIf_Range, HTTP_QUERY_IF_RANGE,}, NULL, /* HTTP_QUERY_FORWARDED = 30 */
{szIf_Unmodified_Since, HTTP_QUERY_IF_UNMODIFIED_SINCE,}, NULL, /* HTTP_QUERY_FROM = 31 */
{szLast_Modified, HTTP_QUERY_LAST_MODIFIED,}, szIf_Modified_Since, /* HTTP_QUERY_IF_MODIFIED_SINCE = 32 */
{szLocation, HTTP_QUERY_LOCATION,}, szLocation, /* HTTP_QUERY_LOCATION = 33 */
{szMax_Forwards, HTTP_QUERY_MAX_FORWARDS,}, NULL, /* HTTP_QUERY_ORIG_URI = 34 */
{szMime_Version, HTTP_QUERY_MIME_VERSION,}, szReferer, /* HTTP_QUERY_REFERER = 35 */
{szPragma, HTTP_QUERY_PRAGMA,}, szRetry_After, /* HTTP_QUERY_RETRY_AFTER = 36 */
{szProxy_Authenticate, HTTP_QUERY_PROXY_AUTHENTICATE,}, szServer, /* HTTP_QUERY_SERVER = 37 */
{szProxy_Authorization, HTTP_QUERY_PROXY_AUTHORIZATION,}, NULL, /* HTTP_TITLE = 38 */
{szProxy_Connection, HTTP_QUERY_PROXY_CONNECTION,}, szUser_Agent, /* HTTP_QUERY_USER_AGENT = 39 */
{szPublic, HTTP_QUERY_PUBLIC,}, szWWW_Authenticate, /* HTTP_QUERY_WWW_AUTHENTICATE = 40 */
{szRange, HTTP_QUERY_RANGE,}, szProxy_Authenticate, /* HTTP_QUERY_PROXY_AUTHENTICATE = 41 */
{szReferer, HTTP_QUERY_REFERER,}, szAccept_Ranges, /* HTTP_QUERY_ACCEPT_RANGES = 42 */
{szRetry_After, HTTP_QUERY_RETRY_AFTER,}, szSet_Cookie, /* HTTP_QUERY_SET_COOKIE = 43 */
{szServer, HTTP_QUERY_SERVER,}, szCookie, /* HTTP_QUERY_COOKIE = 44 */
{szSet_Cookie, HTTP_QUERY_SET_COOKIE,}, NULL, /* HTTP_QUERY_REQUEST_METHOD = 45 */
{szStatus, HTTP_QUERY_STATUS_CODE,}, NULL, /* HTTP_QUERY_REFRESH = 46 */
{szTransfer_Encoding, HTTP_QUERY_TRANSFER_ENCODING,}, NULL, /* HTTP_QUERY_CONTENT_DISPOSITION = 47 */
{szUnless_Modified_Since, HTTP_QUERY_UNLESS_MODIFIED_SINCE,}, szAge, /* HTTP_QUERY_AGE = 48 */
{szUpgrade, HTTP_QUERY_UPGRADE,}, szCache_Control, /* HTTP_QUERY_CACHE_CONTROL = 49 */
{szURI, HTTP_QUERY_URI,}, szContent_Base, /* HTTP_QUERY_CONTENT_BASE = 50 */
{szUser_Agent, HTTP_QUERY_USER_AGENT,}, szContent_Location, /* HTTP_QUERY_CONTENT_LOCATION = 51 */
{szVary, HTTP_QUERY_VARY,}, szContent_MD5, /* HTTP_QUERY_CONTENT_MD5 = 52 */
{szVia, HTTP_QUERY_VIA,}, szContent_Range, /* HTTP_QUERY_CONTENT_RANGE = 53 */
{szWarning, HTTP_QUERY_WARNING,}, szETag, /* HTTP_QUERY_ETAG = 54 */
{szWWW_Authenticate, HTTP_QUERY_WWW_AUTHENTICATE,}, szHost, /* HTTP_QUERY_HOST = 55 */
szIf_Match, /* HTTP_QUERY_IF_MATCH = 56 */
szIf_None_Match, /* HTTP_QUERY_IF_NONE_MATCH = 57 */
szIf_Range, /* HTTP_QUERY_IF_RANGE = 58 */
szIf_Unmodified_Since, /* HTTP_QUERY_IF_UNMODIFIED_SINCE = 59 */
szMax_Forwards, /* HTTP_QUERY_MAX_FORWARDS = 60 */
szProxy_Authorization, /* HTTP_QUERY_PROXY_AUTHORIZATION = 61 */
szRange, /* HTTP_QUERY_RANGE = 62 */
szTransfer_Encoding, /* HTTP_QUERY_TRANSFER_ENCODING = 63 */
szUpgrade, /* HTTP_QUERY_UPGRADE = 64 */
szVary, /* HTTP_QUERY_VARY = 65 */
szVia, /* HTTP_QUERY_VIA = 66 */
szWarning, /* HTTP_QUERY_WARNING = 67 */
szExpect, /* HTTP_QUERY_EXPECT = 68 */
szProxy_Connection, /* HTTP_QUERY_PROXY_CONNECTION = 69 */
szUnless_Modified_Since, /* HTTP_QUERY_UNLESS_MODIFIED_SINCE = 70 */
}; };
#define LAST_TABLE_HEADER (sizeof(header_lookup)/sizeof(header_lookup[0]))
/*********************************************************************** /***********************************************************************
* HTTP_HttpQueryInfoW (internal) * HTTP_HttpQueryInfoW (internal)
*/ */
...@@ -1384,20 +1395,11 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD dwInfoLev ...@@ -1384,20 +1395,11 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD dwInfoLev
return TRUE; return TRUE;
} }
default: default:
if (level >= 0 && level <= HTTP_QUERY_MAX ) assert (LAST_TABLE_HEADER == (HTTP_QUERY_UNLESS_MODIFIED_SINCE + 1));
{
int i; if (level >= 0 && level < LAST_TABLE_HEADER && header_lookup[level])
for (i = 0; i < sizeof(SORTED_STANDARD_HEADERS)/sizeof(std_hdr_data) ; i++) index = HTTP_GetCustomHeaderIndex(lpwhr, header_lookup[level],
{ requested_index,request_only);
if (SORTED_STANDARD_HEADERS[i].hdrIndex == level)
{
index = HTTP_GetCustomHeaderIndex(lpwhr,
(LPWSTR)SORTED_STANDARD_HEADERS[i].hdrStr,
requested_index,request_only);
break;
}
}
}
} }
if (index >= 0) if (index >= 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment