ReactOS  0.4.13-dev-92-gf251225
http.c File Reference
#include "config.h"
#include <stdlib.h>
#include "winsock2.h"
#include "ws2ipdef.h"
#include <stdarg.h>
#include <stdio.h>
#include <time.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wininet.h"
#include "winerror.h"
#include "winternl.h"
#include "shlwapi.h"
#include "sspi.h"
#include "wincrypt.h"
#include "winuser.h"
#include "internet.h"
#include "wine/debug.h"
#include "wine/exception.h"
#include "wine/unicode.h"
Include dependency graph for http.c:

Go to the source code of this file.

Classes

struct  HttpAuthInfo
 
struct  _basicAuthorizationData
 
struct  _authorizationData
 
struct  data_stream_vtbl_t
 
struct  chunked_stream_t
 
struct  read_file_task_t
 
struct  send_request_task_t
 
struct  end_request_task_t
 

Macros

#define NO_SHLWAPI_STREAM
 
#define NO_SHLWAPI_REG
 
#define NO_SHLWAPI_STRFCNS
 
#define NO_SHLWAPI_GDI
 
#define HTTP_REFERER   szReferer
 
#define HTTP_ACCEPT   szAccept
 
#define HTTP_USERAGENT   szUser_Agent
 
#define HTTP_ADDHDR_FLAG_ADD   0x20000000
 
#define HTTP_ADDHDR_FLAG_ADD_IF_NEW   0x10000000
 
#define HTTP_ADDHDR_FLAG_COALESCE   0x40000000
 
#define HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA   0x40000000
 
#define HTTP_ADDHDR_FLAG_COALESCE_WITH_SEMICOLON   0x01000000
 
#define HTTP_ADDHDR_FLAG_REPLACE   0x80000000
 
#define HTTP_ADDHDR_FLAG_REQ   0x02000000
 
#define COLLECT_TIME   60000
 
#define ARRAYSIZE(array)   (sizeof(array)/sizeof((array)[0]))
 
#define LAST_TABLE_HEADER   (sizeof(header_lookup)/sizeof(header_lookup[0]))
 
#define FE(x)   { x, #x }
 
#define COALESCEFLAGS   (HTTP_ADDHDR_FLAG_COALESCE|HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA|HTTP_ADDHDR_FLAG_COALESCE_WITH_SEMICOLON)
 

Typedefs

typedef struct _basicAuthorizationData basicAuthorizationData
 
typedef struct _authorizationData authorizationData
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wininet)
 
static DWORD HTTP_GetResponseHeaders (http_request_t *req, INT *len)
 
static DWORD HTTP_ProcessHeader (http_request_t *req, LPCWSTR field, LPCWSTR value, DWORD dwModifier)
 
static LPWSTRHTTP_InterpretHttpHeader (LPCWSTR buffer)
 
static DWORD HTTP_InsertCustomHeader (http_request_t *req, LPHTTPHEADERW lpHdr)
 
static INT HTTP_GetCustomHeaderIndex (http_request_t *req, LPCWSTR lpszField, INT index, BOOL Request)
 
static BOOL HTTP_DeleteCustomHeader (http_request_t *req, DWORD index)
 
static LPWSTR HTTP_build_req (LPCWSTR *list, int len)
 
static DWORD HTTP_HttpQueryInfoW (http_request_t *, DWORD, LPVOID, LPDWORD, LPDWORD)
 
static UINT HTTP_DecodeBase64 (LPCWSTR base64, LPSTR bin)
 
static DWORD drain_content (http_request_t *, BOOL)
 
void server_addref (server_t *server)
 
void server_release (server_t *server)
 
static BOOL process_host_port (server_t *server)
 
server_tget_server (substr_t name, INTERNET_PORT port, BOOL is_https, BOOL do_create)
 
BOOL collect_connections (collect_type_t collect_type)
 
static DWORD WINAPI collect_connections_proc (void *arg)
 
static LPHTTPHEADERW HTTP_GetHeader (http_request_t *req, LPCWSTR head)
 
static WCHARget_host_header (http_request_t *req)
 
static void destroy_data_stream (data_stream_t *stream)
 
static void reset_data_stream (http_request_t *req)
 
static void remove_header (http_request_t *request, const WCHAR *str, BOOL from_request)
 
static DWORD init_gzip_stream (http_request_t *req, BOOL is_gzip)
 
static void HTTP_FreeTokens (LPWSTR *token_array)
 
static void HTTP_FixURL (http_request_t *request)
 
static WCHARbuild_request_header (http_request_t *request, const WCHAR *verb, const WCHAR *path, const WCHAR *version, BOOL use_cr)
 
static WCHARbuild_response_header (http_request_t *request, BOOL use_cr)
 
static void HTTP_ProcessCookies (http_request_t *request)
 
static void strip_spaces (LPWSTR start)
 
static BOOL is_basic_auth_value (LPCWSTR pszAuthValue, LPWSTR *pszRealm)
 
static void destroy_authinfo (struct HttpAuthInfo *authinfo)
 
static UINT retrieve_cached_basic_authorization (const WCHAR *host, const WCHAR *realm, char **auth_data)
 
static void cache_basic_authorization (LPWSTR host, LPWSTR realm, LPSTR auth_data, UINT auth_data_len)
 
static BOOL retrieve_cached_authorization (LPWSTR host, LPWSTR scheme, SEC_WINNT_AUTH_IDENTITY_W *nt_auth_identity)
 
static void cache_authorization (LPWSTR host, LPWSTR scheme, SEC_WINNT_AUTH_IDENTITY_W *nt_auth_identity)
 
static BOOL HTTP_DoAuthorization (http_request_t *request, LPCWSTR pszAuthValue, struct HttpAuthInfo **ppAuthInfo, LPWSTR domain_and_username, LPWSTR password, LPWSTR host)
 
static DWORD HTTP_HttpAddRequestHeadersW (http_request_t *request, LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
 
BOOL WINAPI HttpAddRequestHeadersW (HINTERNET hHttpRequest, LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
 
BOOL WINAPI HttpAddRequestHeadersA (HINTERNET hHttpRequest, LPCSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
 
static void free_accept_types (WCHAR **accept_types)
 
static WCHAR ** convert_accept_types (const char **accept_types)
 
HINTERNET WINAPI HttpOpenRequestA (HINTERNET hHttpSession, LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion, LPCSTR lpszReferrer, LPCSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
 
static UINT HTTP_EncodeBase64 (LPCSTR bin, unsigned int len, LPWSTR base64)
 
static WCHARencode_auth_data (const WCHAR *scheme, const char *data, UINT data_len)
 
static BOOL HTTP_InsertAuthorization (http_request_t *request, struct HttpAuthInfo *pAuthInfo, LPCWSTR header)
 
static WCHARbuild_proxy_path_url (http_request_t *req)
 
static BOOL HTTP_DomainMatches (LPCWSTR server, substr_t domain)
 
static BOOL HTTP_ShouldBypassProxy (appinfo_t *lpwai, LPCWSTR server)
 
static BOOL HTTP_DealWithProxy (appinfo_t *hIC, http_session_t *session, http_request_t *request)
 
static DWORD HTTP_ResolveName (http_request_t *request)
 
static WCHARcompose_request_url (http_request_t *req)
 
static void HTTPREQ_Destroy (object_header_t *hdr)
 
static void http_release_netconn (http_request_t *req, BOOL reuse)
 
static BOOL HTTP_KeepAlive (http_request_t *request)
 
static void HTTPREQ_CloseConnection (object_header_t *hdr)
 
static DWORD str_to_buffer (const WCHAR *str, void *buffer, DWORD *size, BOOL unicode)
 
static DWORD HTTPREQ_QueryOption (object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
 
static DWORD HTTPREQ_SetOption (object_header_t *hdr, DWORD option, void *buffer, DWORD size)
 
static void commit_cache_entry (http_request_t *req)
 
static void create_cache_entry (http_request_t *req)
 
static DWORD read_more_data (http_request_t *req, int maxlen)
 
static void remove_data (http_request_t *req, int count)
 
static DWORD read_line (http_request_t *req, LPSTR buffer, DWORD *len)
 
static BOOL end_of_read_data (http_request_t *req)
 
static DWORD read_http_stream (http_request_t *req, BYTE *buf, DWORD size, DWORD *read, BOOL allow_blocking)
 
static DWORD refill_read_buffer (http_request_t *req, BOOL allow_blocking, DWORD *read_bytes)
 
static BOOL netconn_end_of_data (data_stream_t *stream, http_request_t *req)
 
static DWORD netconn_read (data_stream_t *stream, http_request_t *req, BYTE *buf, DWORD size, DWORD *read, BOOL allow_blocking)
 
static DWORD netconn_drain_content (data_stream_t *stream, http_request_t *req, BOOL allow_blocking)
 
static void netconn_destroy (data_stream_t *stream)
 
static char next_chunked_data_char (chunked_stream_t *stream)
 
static BOOL chunked_end_of_data (data_stream_t *stream, http_request_t *req)
 
static DWORD chunked_read (data_stream_t *stream, http_request_t *req, BYTE *buf, DWORD size, DWORD *read, BOOL allow_blocking)
 
static DWORD chunked_drain_content (data_stream_t *stream, http_request_t *req, BOOL allow_blocking)
 
static void chunked_destroy (data_stream_t *stream)
 
static DWORD set_content_length (http_request_t *request)
 
static void send_request_complete (http_request_t *req, DWORD_PTR result, DWORD error)
 
static void HTTP_ReceiveRequestData (http_request_t *req)
 
static DWORD HTTPREQ_Read (http_request_t *req, void *buffer, DWORD size, DWORD *read, BOOL allow_blocking)
 
static void async_read_file_proc (task_header_t *hdr)
 
static DWORD async_read (http_request_t *req, void *buf, DWORD size, DWORD read_pos, DWORD *ret_read)
 
static DWORD HTTPREQ_ReadFile (object_header_t *hdr, void *buf, DWORD size, DWORD *ret_read, DWORD flags, DWORD_PTR context)
 
static DWORD HTTPREQ_WriteFile (object_header_t *hdr, const void *buffer, DWORD size, DWORD *written)
 
static DWORD HTTPREQ_QueryDataAvailable (object_header_t *hdr, DWORD *available, DWORD flags, DWORD_PTR ctx)
 
static DWORD HTTPREQ_LockRequestFile (object_header_t *hdr, req_file_t **ret)
 
static DWORD HTTP_HttpOpenRequestW (http_session_t *session, LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion, LPCWSTR lpszReferrer, LPCWSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext, HINTERNET *ret)
 
HINTERNET WINAPI HttpOpenRequestW (HINTERNET hHttpSession, LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion, LPCWSTR lpszReferrer, LPCWSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
 
BOOL WINAPI HttpQueryInfoW (HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
 
BOOL WINAPI HttpQueryInfoA (HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
 
static WCHARget_redirect_url (http_request_t *request)
 
static DWORD HTTP_HandleRedirect (http_request_t *request, WCHAR *url)
 
static void HTTP_InsertCookies (http_request_t *request)
 
static WORD HTTP_ParseWkday (LPCWSTR day)
 
static WORD HTTP_ParseMonth (LPCWSTR month)
 
static BOOL HTTP_ParseTime (SYSTEMTIME *st, LPCWSTR *str)
 
static BOOL HTTP_ParseDateAsAsctime (LPCWSTR value, FILETIME *ft)
 
static BOOL HTTP_ParseRfc1123Date (LPCWSTR value, FILETIME *ft)
 
static WORD HTTP_ParseWeekday (LPCWSTR day)
 
static BOOL HTTP_ParseRfc850Date (LPCWSTR value, FILETIME *ft)
 
static BOOL HTTP_ParseDate (LPCWSTR value, FILETIME *ft)
 
static void HTTP_ProcessExpires (http_request_t *request)
 
static void HTTP_ProcessLastModified (http_request_t *request)
 
static void http_process_keep_alive (http_request_t *req)
 
static DWORD open_http_connection (http_request_t *request, BOOL *reusing)
 
static charbuild_ascii_request (const WCHAR *str, void *data, DWORD data_len, DWORD *out_len)
 
static void set_content_length_header (http_request_t *request, DWORD len, DWORD flags)
 
static DWORD HTTP_HttpSendRequestW (http_request_t *request, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength, DWORD dwContentLength, BOOL bEndRequest)
 
static void AsyncHttpSendRequestProc (task_header_t *hdr)
 
static DWORD HTTP_HttpEndRequestW (http_request_t *request, DWORD dwFlags, DWORD_PTR dwContext)
 
BOOL WINAPI HttpEndRequestA (HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
 
static void AsyncHttpEndRequestProc (task_header_t *hdr)
 
BOOL WINAPI HttpEndRequestW (HINTERNET hRequest, LPINTERNET_BUFFERSW lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
 
BOOL WINAPI HttpSendRequestExA (HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffersIn, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
 
BOOL WINAPI HttpSendRequestExW (HINTERNET hRequest, LPINTERNET_BUFFERSW lpBuffersIn, LPINTERNET_BUFFERSW lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
 
BOOL WINAPI HttpSendRequestW (HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
 
BOOL WINAPI HttpSendRequestA (HINTERNET hHttpRequest, LPCSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
 
static void HTTPSESSION_Destroy (object_header_t *hdr)
 
static DWORD HTTPSESSION_QueryOption (object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
 
static DWORD HTTPSESSION_SetOption (object_header_t *hdr, DWORD option, void *buffer, DWORD size)
 
DWORD HTTP_Connect (appinfo_t *hIC, LPCWSTR lpszServerName, INTERNET_PORT serverPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext, DWORD dwInternalFlags, HINTERNET *ret)
 
static void HTTP_clear_response_headers (http_request_t *request)
 
static INT HTTP_GetCustomHeaderIndex (http_request_t *request, LPCWSTR lpszField, int requested_index, BOOL request_only)
 
BOOL WINAPI IsHostInProxyBypassList (DWORD flags, LPCSTR szHost, DWORD length)
 

Variables

static const WCHAR g_szHttp1_0 [] = {'H','T','T','P','/','1','.','0',0}
 
static const WCHAR g_szHttp1_1 [] = {'H','T','T','P','/','1','.','1',0}
 
static const WCHAR szOK [] = {'O','K',0}
 
static const WCHAR hostW [] = { 'H','o','s','t',0 }
 
static const WCHAR szAuthorization [] = { 'A','u','t','h','o','r','i','z','a','t','i','o','n',0 }
 
static const WCHAR szProxy_Authorization [] = { 'P','r','o','x','y','-','A','u','t','h','o','r','i','z','a','t','i','o','n',0 }
 
static const WCHAR szStatus [] = { 'S','t','a','t','u','s',0 }
 
static const WCHAR szKeepAlive [] = {'K','e','e','p','-','A','l','i','v','e',0}
 
static const WCHAR szGET [] = { 'G','E','T', 0 }
 
static const WCHAR szHEAD [] = { 'H','E','A','D', 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_Encoding [] = { 'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0 }
 
static const WCHAR szAccept_Language [] = { 'A','c','c','e','p','t','-','L','a','n','g','u','a','g','e',0 }
 
static const WCHAR szAccept_Ranges [] = { 'A','c','c','e','p','t','-','R','a','n','g','e','s',0 }
 
static const WCHAR szAge [] = { 'A','g','e',0 }
 
static const WCHAR szAllow [] = { 'A','l','l','o','w',0 }
 
static const WCHAR szCache_Control [] = { 'C','a','c','h','e','-','C','o','n','t','r','o','l',0 }
 
static const WCHAR szConnection [] = { 'C','o','n','n','e','c','t','i','o','n',0 }
 
static const WCHAR szContent_Base [] = { 'C','o','n','t','e','n','t','-','B','a','s','e',0 }
 
static const WCHAR szContent_Disposition [] = { 'C','o','n','t','e','n','t','-','D','i','s','p','o','s','i','t','i','o','n',0 }
 
static const WCHAR szContent_Encoding [] = { 'C','o','n','t','e','n','t','-','E','n','c','o','d','i','n','g',0 }
 
static const WCHAR szContent_ID [] = { 'C','o','n','t','e','n','t','-','I','D',0 }
 
static const WCHAR szContent_Language [] = { 'C','o','n','t','e','n','t','-','L','a','n','g','u','a','g','e',0 }
 
static const WCHAR szContent_Length [] = { 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',0 }
 
static const WCHAR szContent_Location [] = { 'C','o','n','t','e','n','t','-','L','o','c','a','t','i','o','n',0 }
 
static const WCHAR szContent_MD5 [] = { 'C','o','n','t','e','n','t','-','M','D','5',0 }
 
static const WCHAR szContent_Range [] = { 'C','o','n','t','e','n','t','-','R','a','n','g','e',0 }
 
static const WCHAR szContent_Transfer_Encoding [] = { 'C','o','n','t','e','n','t','-','T','r','a','n','s','f','e','r','-','E','n','c','o','d','i','n','g',0 }
 
static const WCHAR szContent_Type [] = { 'C','o','n','t','e','n','t','-','T','y','p','e',0 }
 
static const WCHAR szCookie [] = { 'C','o','o','k','i','e',0 }
 
static const WCHAR szDate [] = { 'D','a','t','e',0 }
 
static const WCHAR szFrom [] = { 'F','r','o','m',0 }
 
static const WCHAR szETag [] = { 'E','T','a','g',0 }
 
static const WCHAR szExpect [] = { 'E','x','p','e','c','t',0 }
 
static const WCHAR szExpires [] = { 'E','x','p','i','r','e','s',0 }
 
static const WCHAR szIf_Match [] = { 'I','f','-','M','a','t','c','h',0 }
 
static const WCHAR szIf_Modified_Since [] = { 'I','f','-','M','o','d','i','f','i','e','d','-','S','i','n','c','e',0 }
 
static const WCHAR szIf_None_Match [] = { 'I','f','-','N','o','n','e','-','M','a','t','c','h',0 }
 
static const WCHAR szIf_Range [] = { 'I','f','-','R','a','n','g','e',0 }
 
static const WCHAR szIf_Unmodified_Since [] = { 'I','f','-','U','n','m','o','d','i','f','i','e','d','-','S','i','n','c','e',0 }
 
static const WCHAR szLast_Modified [] = { 'L','a','s','t','-','M','o','d','i','f','i','e','d',0 }
 
static const WCHAR szLocation [] = { 'L','o','c','a','t','i','o','n',0 }
 
static const WCHAR szMax_Forwards [] = { 'M','a','x','-','F','o','r','w','a','r','d','s',0 }
 
static const WCHAR szMime_Version [] = { 'M','i','m','e','-','V','e','r','s','i','o','n',0 }
 
static const WCHAR szPragma [] = { 'P','r','a','g','m','a',0 }
 
static const WCHAR szProxy_Authenticate [] = { 'P','r','o','x','y','-','A','u','t','h','e','n','t','i','c','a','t','e',0 }
 
static const WCHAR szProxy_Connection [] = { 'P','r','o','x','y','-','C','o','n','n','e','c','t','i','o','n',0 }
 
static const WCHAR szPublic [] = { 'P','u','b','l','i','c',0 }
 
static const WCHAR szRange [] = { 'R','a','n','g','e',0 }
 
static const WCHAR szReferer [] = { 'R','e','f','e','r','e','r',0 }
 
static const WCHAR szRetry_After [] = { 'R','e','t','r','y','-','A','f','t','e','r',0 }
 
static const WCHAR szServer [] = { 'S','e','r','v','e','r',0 }
 
static const WCHAR szSet_Cookie [] = { 'S','e','t','-','C','o','o','k','i','e',0 }
 
static const WCHAR szTransfer_Encoding [] = { 'T','r','a','n','s','f','e','r','-','E','n','c','o','d','i','n','g',0 }
 
static const WCHAR szUnless_Modified_Since [] = { 'U','n','l','e','s','s','-','M','o','d','i','f','i','e','d','-','S','i','n','c','e',0 }
 
static const WCHAR szUpgrade [] = { 'U','p','g','r','a','d','e',0 }
 
static const WCHAR szURI [] = { 'U','R','I',0 }
 
static const WCHAR szUser_Agent [] = { 'U','s','e','r','-','A','g','e','n','t',0 }
 
static const WCHAR szVary [] = { 'V','a','r','y',0 }
 
static const WCHAR szVia [] = { 'V','i','a',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 emptyW [] = {0}
 
static struct list basicAuthorizationCache = LIST_INIT(basicAuthorizationCache)
 
static struct list authorizationCache = LIST_INIT(authorizationCache)
 
static CRITICAL_SECTION authcache_cs = { &critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG critsect_debug
 
static CRITICAL_SECTION connection_pool_cs = { &connection_pool_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG connection_pool_debug
 
static struct list connection_pool = LIST_INIT(connection_pool)
 
static BOOL collector_running
 
static const signed char HTTP_Base64Dec []
 
static const data_stream_vtbl_t netconn_stream_vtbl
 
static const data_stream_vtbl_t chunked_stream_vtbl
 
static const object_vtbl_t HTTPREQVtbl
 
static const LPCWSTR header_lookup []
 
static const object_vtbl_t HTTPSESSIONVtbl
 

Macro Definition Documentation

◆ ARRAYSIZE

#define ARRAYSIZE (   array)    (sizeof(array)/sizeof((array)[0]))

Definition at line 149 of file http.c.

◆ COALESCEFLAGS

◆ COLLECT_TIME

#define COLLECT_TIME   60000

Definition at line 146 of file http.c.

◆ FE

#define FE (   x)    { x, #x }

◆ HTTP_ACCEPT

#define HTTP_ACCEPT   szAccept

Definition at line 135 of file http.c.

◆ HTTP_ADDHDR_FLAG_ADD

#define HTTP_ADDHDR_FLAG_ADD   0x20000000

Definition at line 138 of file http.c.

◆ HTTP_ADDHDR_FLAG_ADD_IF_NEW

#define HTTP_ADDHDR_FLAG_ADD_IF_NEW   0x10000000

Definition at line 139 of file http.c.

◆ HTTP_ADDHDR_FLAG_COALESCE

#define HTTP_ADDHDR_FLAG_COALESCE   0x40000000

Definition at line 140 of file http.c.

◆ HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA

#define HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA   0x40000000

Definition at line 141 of file http.c.

◆ HTTP_ADDHDR_FLAG_COALESCE_WITH_SEMICOLON

#define HTTP_ADDHDR_FLAG_COALESCE_WITH_SEMICOLON   0x01000000

Definition at line 142 of file http.c.

◆ HTTP_ADDHDR_FLAG_REPLACE

#define HTTP_ADDHDR_FLAG_REPLACE   0x80000000

Definition at line 143 of file http.c.

◆ HTTP_ADDHDR_FLAG_REQ

#define HTTP_ADDHDR_FLAG_REQ   0x02000000

Definition at line 144 of file http.c.

◆ HTTP_REFERER

#define HTTP_REFERER   szReferer

Definition at line 134 of file http.c.

◆ HTTP_USERAGENT

#define HTTP_USERAGENT   szUser_Agent

Definition at line 136 of file http.c.

◆ LAST_TABLE_HEADER

#define LAST_TABLE_HEADER   (sizeof(header_lookup)/sizeof(header_lookup[0]))

Definition at line 3539 of file http.c.

◆ NO_SHLWAPI_GDI

#define NO_SHLWAPI_GDI

Definition at line 54 of file http.c.

◆ NO_SHLWAPI_REG

#define NO_SHLWAPI_REG

Definition at line 52 of file http.c.

◆ NO_SHLWAPI_STREAM

#define NO_SHLWAPI_STREAM

Definition at line 51 of file http.c.

◆ NO_SHLWAPI_STRFCNS

#define NO_SHLWAPI_STRFCNS

Definition at line 53 of file http.c.

Typedef Documentation

◆ authorizationData

◆ basicAuthorizationData

Function Documentation

◆ async_read()

static DWORD async_read ( http_request_t req,
void buf,
DWORD  size,
DWORD  read_pos,
DWORD ret_read 
)
static

Definition at line 3105 of file http.c.

3106 {
3107  read_file_task_t *task;
3108 
3109  task = alloc_async_task(&req->hdr, async_read_file_proc, sizeof(*task));
3110  if(!task)
3111  return ERROR_OUTOFMEMORY;
3112 
3113  task->buf = buf;
3114  task->size = size;
3115  task->read_pos = read_pos;
3116  task->ret_read = ret_read;
3117 
3118  INTERNET_AsyncCall(&task->hdr);
3119  return ERROR_IO_PENDING;
3120 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ERROR_IO_PENDING
Definition: dderror.h:15
task_header_t hdr
Definition: http.c:3058
object_header_t hdr
Definition: internet.h:346
DWORD * ret_read
Definition: http.c:3062
DWORD read_pos
Definition: http.c:3061
GLsizeiptr size
Definition: glext.h:5919
void * buf
Definition: http.c:3059
void * alloc_async_task(object_header_t *hdr, async_task_proc_t proc, size_t size)
Definition: internet.c:3780
DWORD INTERNET_AsyncCall(task_header_t *task)
Definition: internet.c:3801
DWORD size
Definition: http.c:3060
static void async_read_file_proc(task_header_t *hdr)
Definition: http.c:3065
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by HTTPREQ_QueryDataAvailable(), and HTTPREQ_ReadFile().

◆ async_read_file_proc()

static void async_read_file_proc ( task_header_t hdr)
static

Definition at line 3065 of file http.c.

3066 {
3068  http_request_t *req = (http_request_t*)task->hdr.hdr;
3069  DWORD res = ERROR_SUCCESS, read = task->read_pos, complete_arg = 0;
3070 
3071  TRACE("req %p buf %p size %u read_pos %u ret_read %p\n", req, task->buf, task->size, task->read_pos, task->ret_read);
3072 
3073  if(task->buf) {
3074  DWORD read_bytes;
3075  while (read < task->size) {
3076  res = HTTPREQ_Read(req, (char*)task->buf + read, task->size - read, &read_bytes, TRUE);
3077  if (res != ERROR_SUCCESS || !read_bytes)
3078  break;
3079  read += read_bytes;
3080  }
3081  }else {
3083  res = refill_read_buffer(req, TRUE, &read);
3085 
3086  if(task->ret_read)
3087  complete_arg = read; /* QueryDataAvailable reports read bytes in request complete notification */
3088  if(res != ERROR_SUCCESS || !read)
3090  }
3091 
3092  TRACE("res %u read %u\n", res, read);
3093 
3094  if(task->ret_read)
3095  *task->ret_read = read;
3096 
3097  /* FIXME: We should report bytes transferred before decoding content. */
3099 
3100  if(res != ERROR_SUCCESS)
3101  complete_arg = res;
3102  send_request_complete(req, res == ERROR_SUCCESS, complete_arg);
3103 }
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define ERROR_SUCCESS
Definition: deptool.c:10
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:169
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static DWORD HTTPREQ_Read(http_request_t *req, void *buffer, DWORD size, DWORD *read, BOOL allow_blocking)
Definition: http.c:3001
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
task_header_t hdr
Definition: http.c:3058
object_header_t hdr
Definition: internet.h:346
DWORD * ret_read
Definition: http.c:3062
DWORD read_pos
Definition: http.c:3061
static void send_request_complete(http_request_t *req, DWORD_PTR result, DWORD error)
Definition: http.c:2962
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
static void http_release_netconn(http_request_t *req, BOOL reuse)
Definition: http.c:1951
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD drain_content(http_request_t *, BOOL)
Definition: http.c:3039
void * buf
Definition: http.c:3059
object_header_t * hdr
Definition: internet.h:391
static DWORD refill_read_buffer(http_request_t *req, BOOL allow_blocking, DWORD *read_bytes)
Definition: http.c:2604
CRITICAL_SECTION read_section
Definition: internet.h:374
GLuint res
Definition: glext.h:9613
DWORD size
Definition: http.c:3060
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define INTERNET_STATUS_RESPONSE_RECEIVED
Definition: wininet.h:890
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

Referenced by async_read().

◆ AsyncHttpEndRequestProc()

static void AsyncHttpEndRequestProc ( task_header_t hdr)
static

Definition at line 5339 of file http.c.

5340 {
5342  http_request_t *req = (http_request_t*)task->hdr.hdr;
5343 
5344  TRACE("%p\n", req);
5345 
5346  HTTP_HttpEndRequestW(req, task->flags, task->context);
5347 }
char hdr[14]
Definition: iptest.cpp:33
task_header_t hdr
Definition: http.c:5334
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5239

Referenced by HttpEndRequestW().

◆ AsyncHttpSendRequestProc()

static void AsyncHttpSendRequestProc ( task_header_t hdr)
static

Definition at line 5225 of file http.c.

5226 {
5229 
5230  TRACE("%p\n", request);
5231 
5233  task->optional_len, task->content_len, task->end_request);
5234 
5235  heap_free(task->headers);
5236 }
char hdr[14]
Definition: iptest.cpp:33
DWORD headers_len
Definition: http.c:5213
void * optional
Definition: http.c:5214
DWORD optional_len
Definition: http.c:5215
WCHAR * headers
Definition: http.c:5212
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
task_header_t hdr
Definition: http.c:5211
Definition: tftpd.h:85
DWORD content_len
Definition: http.c:5216
static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength, DWORD dwContentLength, BOOL bEndRequest)
Definition: http.c:4872
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HttpSendRequestExW(), and HttpSendRequestW().

◆ build_ascii_request()

static char* build_ascii_request ( const WCHAR str,
void data,
DWORD  data_len,
DWORD out_len 
)
static

Definition at line 4839 of file http.c.

4840 {
4841  int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
4842  char *ret;
4843 
4844  if (!(ret = heap_alloc( len + data_len ))) return NULL;
4845  WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
4846  if (data_len) memcpy( ret + len - 1, data, data_len );
4847  *out_len = len + data_len - 1;
4848  ret[*out_len] = 0;
4849  return ret;
4850 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722

Referenced by HTTP_HttpSendRequestW().

◆ build_proxy_path_url()

static WCHAR* build_proxy_path_url ( http_request_t req)
static

Definition at line 1708 of file http.c.

1709 {
1710  DWORD size, len;
1711  WCHAR *url;
1712 
1714  size = len + strlenW(req->path) + 1;
1715  if(*req->path != '/')
1716  size++;
1717  url = heap_alloc(size * sizeof(WCHAR));
1718  if(!url)
1719  return NULL;
1720 
1721  memcpy(url, req->server->scheme_host_port, len*sizeof(WCHAR));
1722  if(*req->path != '/')
1723  url[len++] = '/';
1724 
1725  strcpyW(url+len, req->path);
1726 
1727  TRACE("url=%s\n", debugstr_w(url));
1728  return url;
1729 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR url[]
Definition: encode.c:1432
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
server_t * server
Definition: internet.h:348
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
WCHAR * scheme_host_port
Definition: internet.h:44
LPWSTR path
Definition: internet.h:350

Referenced by HTTP_HttpSendRequestW().

◆ build_request_header()

static WCHAR* build_request_header ( http_request_t request,
const WCHAR verb,
const WCHAR path,
const WCHAR version,
BOOL  use_cr 
)
static

Definition at line 649 of file http.c.

651 {
652  static const WCHAR szSpace[] = {' ',0};
653  static const WCHAR szColon[] = {':',' ',0};
654  static const WCHAR szCr[] = {'\r',0};
655  static const WCHAR szLf[] = {'\n',0};
656  LPWSTR requestString;
657  DWORD len, n;
658  LPCWSTR *req;
659  UINT i;
660 
661  EnterCriticalSection( &request->headers_section );
662 
663  /* allocate space for an array of all the string pointers to be added */
664  len = request->nCustHeaders * 5 + 10;
665  if (!(req = heap_alloc( len * sizeof(const WCHAR *) )))
666  {
667  LeaveCriticalSection( &request->headers_section );
668  return NULL;
669  }
670 
671  /* add the verb, path and HTTP version string */
672  n = 0;
673  req[n++] = verb;
674  req[n++] = szSpace;
675  req[n++] = path;
676  req[n++] = szSpace;
677  req[n++] = version;
678  if (use_cr)
679  req[n++] = szCr;
680  req[n++] = szLf;
681 
682  /* Append custom request headers */
683  for (i = 0; i < request->nCustHeaders; i++)
684  {
685  if (request->custHeaders[i].wFlags & HDR_ISREQUEST)
686  {
687  req[n++] = request->custHeaders[i].lpszField;
688  req[n++] = szColon;
689  req[n++] = request->custHeaders[i].lpszValue;
690  if (use_cr)
691  req[n++] = szCr;
692  req[n++] = szLf;
693 
694  TRACE("Adding custom header %s (%s)\n",
695  debugstr_w(request->custHeaders[i].lpszField),
696  debugstr_w(request->custHeaders[i].lpszValue));
697  }
698  }
699  if (use_cr)
700  req[n++] = szCr;
701  req[n++] = szLf;
702  req[n] = NULL;
703 
704  requestString = HTTP_build_req( req, 4 );
705  heap_free( req );
706  LeaveCriticalSection( &request->headers_section );
707  return requestString;
708 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
GLsizei const GLchar ** path
Definition: glext.h:7234
GLdouble n
Definition: glext.h:7729
static LPWSTR HTTP_build_req(LPCWSTR *list, int len)
Definition: http.c:4194
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static const WCHAR szSpace[]
Definition: msipriv.h:1110
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define HDR_ISREQUEST
Definition: internet.h:315
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:64
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50
Definition: tftpd.h:85
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HTTP_HttpQueryInfoW(), and HTTP_HttpSendRequestW().

◆ build_response_header()

static WCHAR* build_response_header ( http_request_t request,
BOOL  use_cr 
)
static

Definition at line 710 of file http.c.

711 {
712  static const WCHAR colonW[] = { ':',' ',0 };
713  static const WCHAR crW[] = { '\r',0 };
714  static const WCHAR lfW[] = { '\n',0 };
715  static const WCHAR status_fmt[] = { ' ','%','u',' ',0 };
716  const WCHAR **req;
717  WCHAR *ret, buf[14];
718  DWORD i, n = 0;
719 
720  EnterCriticalSection( &request->headers_section );
721 
722  if (!(req = heap_alloc( (request->nCustHeaders * 5 + 8) * sizeof(WCHAR *) )))
723  {
724  LeaveCriticalSection( &request->headers_section );
725  return NULL;
726  }
727 
728  if (request->status_code)
729  {
730  req[n++] = request->version;
731  sprintfW(buf, status_fmt, request->status_code);
732  req[n++] = buf;
733  req[n++] = request->statusText;
734  if (use_cr)
735  req[n++] = crW;
736  req[n++] = lfW;
737  }
738 
739  for(i = 0; i < request->nCustHeaders; i++)
740  {
741  if(!(request->custHeaders[i].wFlags & HDR_ISREQUEST)
742  && strcmpW(request->custHeaders[i].lpszField, szStatus))
743  {
744  req[n++] = request->custHeaders[i].lpszField;
745  req[n++] = colonW;
746  req[n++] = request->custHeaders[i].lpszValue;
747  if(use_cr)
748  req[n++] = crW;
749  req[n++] = lfW;
750 
751  TRACE("Adding custom header %s (%s)\n",
752  debugstr_w(request->custHeaders[i].lpszField),
753  debugstr_w(request->custHeaders[i].lpszValue));
754  }
755  }
756  if(use_cr)
757  req[n++] = crW;
758  req[n++] = lfW;
759  req[n] = NULL;
760 
761  ret = HTTP_build_req(req, 0);
762  heap_free(req);
763  LeaveCriticalSection( &request->headers_section );
764  return ret;
765 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble n
Definition: glext.h:7729
static LPWSTR HTTP_build_req(LPCWSTR *list, int len)
Definition: http.c:4194
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define HDR_ISREQUEST
Definition: internet.h:315
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR szStatus[]
Definition: http.c:73
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define sprintfW
Definition: unicode.h:58
Definition: tftpd.h:85
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by commit_cache_entry(), and HTTP_HttpQueryInfoW().

◆ cache_authorization()

static void cache_authorization ( LPWSTR  host,
LPWSTR  scheme,
SEC_WINNT_AUTH_IDENTITY_W nt_auth_identity 
)
static

Definition at line 978 of file http.c.

980 {
981  authorizationData *ad;
982  BOOL found = FALSE;
983 
984  TRACE("Caching authorization for %s:%s\n", debugstr_w(host), debugstr_w(scheme));
985 
988  if(!strcmpiW(host, ad->host) && !strcmpiW(scheme, ad->scheme)) {
989  found = TRUE;
990  break;
991  }
992 
993  if(found) {
994  heap_free(ad->user);
995  heap_free(ad->password);
996  heap_free(ad->domain);
997  } else {
998  ad = heap_alloc(sizeof(authorizationData));
999  if(!ad) {
1001  return;
1002  }
1003 
1004  ad->host = heap_strdupW(host);
1005  ad->scheme = heap_strdupW(scheme);
1007  }
1008 
1009  ad->user = heap_strndupW(nt_auth_identity->User, nt_auth_identity->UserLength);
1010  ad->password = heap_strndupW(nt_auth_identity->Password, nt_auth_identity->PasswordLength);
1011  ad->domain = heap_strndupW(nt_auth_identity->Domain, nt_auth_identity->DomainLength);
1012  ad->user_len = nt_auth_identity->UserLength;
1013  ad->password_len = nt_auth_identity->PasswordLength;
1014  ad->domain_len = nt_auth_identity->DomainLength;
1015 
1016  if(!ad->host || !ad->scheme || !ad->user || !ad->password
1017  || (nt_auth_identity->Domain && !ad->domain)) {
1018  heap_free(ad->host);
1019  heap_free(ad->scheme);
1020  heap_free(ad->user);
1021  heap_free(ad->password);
1022  heap_free(ad->domain);
1023  list_remove(&ad->entry);
1024  heap_free(ad);
1025  }
1026 
1028 }
struct list entry
Definition: http.c:177
unsigned short * Domain
Definition: rpcdce.h:225
#define TRUE
Definition: types.h:120
unsigned short * User
Definition: rpcdce.h:223
LPWSTR password
Definition: http.c:185
static LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
UINT password_len
Definition: http.c:186
LPWSTR domain
Definition: http.c:181
unsigned short * Password
Definition: rpcdce.h:227
uint8_t entry
Definition: isohybrid.c:63
char * host
Definition: whois.c:55
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
DWORD scheme
UINT domain_len
Definition: http.c:182
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
unsigned int BOOL
Definition: ntddk_ex.h:94
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
#define debugstr_w
Definition: kernel32.h:32
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
#define strcmpiW(s1, s2)
Definition: unicode.h:39
LPWSTR scheme
Definition: http.c:180
LPWSTR host
Definition: http.c:179
LPWSTR user
Definition: http.c:183
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static struct list authorizationCache
Definition: http.c:190
static CRITICAL_SECTION authcache_cs
Definition: http.c:192

Referenced by HTTP_DoAuthorization().

◆ cache_basic_authorization()

static void cache_basic_authorization ( LPWSTR  host,
LPWSTR  realm,
LPSTR  auth_data,
UINT  auth_data_len 
)
static

Definition at line 901 of file http.c.

902 {
903  struct list *cursor;
905 
906  TRACE("caching authorization for %s:%s = %s\n",debugstr_w(host),debugstr_w(realm),debugstr_an(auth_data,auth_data_len));
907 
910  {
912  if (!strcmpiW(host,check->host) && !strcmpW(realm,check->realm))
913  {
914  ad = check;
915  break;
916  }
917  }
918 
919  if (ad)
920  {
921  TRACE("Found match in cache, replacing\n");
923  ad->authorization = heap_alloc(auth_data_len);
924  memcpy(ad->authorization, auth_data, auth_data_len);
925  ad->authorizationLen = auth_data_len;
926  }
927  else
928  {
929  ad = heap_alloc(sizeof(basicAuthorizationData));
930  ad->host = heap_strdupW(host);
931  ad->realm = heap_strdupW(realm);
932  ad->authorization = heap_alloc(auth_data_len);
933  memcpy(ad->authorization, auth_data, auth_data_len);
934  ad->authorizationLen = auth_data_len;
936  TRACE("authorization cached\n");
937  }
939 }
static struct list basicAuthorizationCache
Definition: http.c:189
uint8_t entry
Definition: isohybrid.c:63
char * host
Definition: whois.c:55
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
#define debugstr_w
Definition: kernel32.h:32
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
void check(CONTEXT *pContext)
Definition: NtContinue.c:61
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:47
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: _list.h:228
#define strcmpiW(s1, s2)
Definition: unicode.h:39
const char cursor[]
Definition: icontest.c:13
struct list entry
Definition: http.c:167
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define LIST_ENTRY(type)
Definition: queue.h:175
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static CRITICAL_SECTION authcache_cs
Definition: http.c:192

Referenced by HTTP_DoAuthorization().

◆ chunked_destroy()

static void chunked_destroy ( data_stream_t stream)
static

Definition at line 2876 of file http.c.

2877 {
2878  chunked_stream_t *chunked_stream = (chunked_stream_t*)stream;
2879  heap_free(chunked_stream);
2880 }
Definition: parse.h:22
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ chunked_drain_content()

static DWORD chunked_drain_content ( data_stream_t stream,
http_request_t req,
BOOL  allow_blocking 
)
static

Definition at line 2858 of file http.c.

2859 {
2860  chunked_stream_t *chunked_stream = (chunked_stream_t*)stream;
2861  BYTE buf[1024];
2862  DWORD size, res;
2863 
2864  while(chunked_stream->state != CHUNKED_STREAM_STATE_END_OF_STREAM
2865  && chunked_stream->state != CHUNKED_STREAM_STATE_ERROR) {
2866  res = chunked_read(stream, req, buf, sizeof(buf), &size, allow_blocking);
2867  if(res != ERROR_SUCCESS)
2868  return res;
2869  }
2870 
2871  if(chunked_stream->state != CHUNKED_STREAM_STATE_END_OF_STREAM)
2872  return ERROR_NO_DATA;
2873  return ERROR_SUCCESS;
2874 }
enum chunked_stream_t::@563 state
#define ERROR_SUCCESS
Definition: deptool.c:10
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizeiptr size
Definition: glext.h:5919
#define ERROR_NO_DATA
Definition: winerror.h:284
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: parse.h:22
unsigned char BYTE
Definition: mem.h:68
static DWORD chunked_read(data_stream_t *stream, http_request_t *req, BYTE *buf, DWORD size, DWORD *read, BOOL allow_blocking)
Definition: http.c:2715
GLuint res
Definition: glext.h:9613

◆ chunked_end_of_data()

static BOOL chunked_end_of_data ( data_stream_t stream,
http_request_t req 
)
static

Definition at line 2702 of file http.c.

2703 {
2704  chunked_stream_t *chunked_stream = (chunked_stream_t*)stream;
2705  switch(chunked_stream->state) {
2706  case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END:
2707  case CHUNKED_STREAM_STATE_END_OF_STREAM:
2708  case CHUNKED_STREAM_STATE_ERROR:
2709  return TRUE;
2710  default:
2711  return FALSE;
2712  }
2713 }
enum chunked_stream_t::@563 state
#define TRUE
Definition: types.h:120
Definition: parse.h:22

◆ chunked_read()

static DWORD chunked_read ( data_stream_t stream,
http_request_t req,
BYTE buf,
DWORD  size,
DWORD read,
BOOL  allow_blocking 
)
static

Definition at line 2715 of file http.c.

2717 {
2718  chunked_stream_t *chunked_stream = (chunked_stream_t*)stream;
2719  DWORD ret_read = 0, res = ERROR_SUCCESS;
2720  BOOL continue_read = TRUE;
2721  int read_bytes;
2722  char ch;
2723 
2724  do {
2725  TRACE("state %d\n", chunked_stream->state);
2726 
2727  /* Ensure that we have data in the buffer for states that need it. */
2728  if(!chunked_stream->buf_size) {
2729  BOOL blocking_read = allow_blocking;
2730 
2731  switch(chunked_stream->state) {
2732  case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END:
2733  case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE:
2734  /* never allow blocking after 0 chunk size */
2735  if(!chunked_stream->chunk_size)
2736  blocking_read = FALSE;
2737  /* fall through */
2738  case CHUNKED_STREAM_STATE_READING_CHUNK_SIZE:
2739  case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA:
2740  chunked_stream->buf_pos = 0;
2741  res = NETCON_recv(req->netconn, chunked_stream->buf, sizeof(chunked_stream->buf), blocking_read, &read_bytes);
2742  if(res == ERROR_SUCCESS && read_bytes) {
2743  chunked_stream->buf_size += read_bytes;
2744  }else if(res == WSAEWOULDBLOCK) {
2745  if(ret_read || allow_blocking)
2746  res = ERROR_SUCCESS;
2747  continue_read = FALSE;
2748  continue;
2749  }else {
2750  chunked_stream->state = CHUNKED_STREAM_STATE_ERROR;
2751  }
2752  break;
2753  default:
2754  break;
2755  }
2756  }
2757 
2758  switch(chunked_stream->state) {
2759  case CHUNKED_STREAM_STATE_READING_CHUNK_SIZE:
2760  ch = next_chunked_data_char(chunked_stream);
2761 
2762  if(ch >= '0' && ch <= '9') {
2763  chunked_stream->chunk_size = chunked_stream->chunk_size * 16 + ch - '0';
2764  }else if(ch >= 'a' && ch <= 'f') {
2765  chunked_stream->chunk_size = chunked_stream->chunk_size * 16 + ch - 'a' + 10;
2766  }else if (ch >= 'A' && ch <= 'F') {
2767  chunked_stream->chunk_size = chunked_stream->chunk_size * 16 + ch - 'A' + 10;
2768  }else if (ch == ';' || ch == '\r' || ch == '\n') {
2769  TRACE("reading %u byte chunk\n", chunked_stream->chunk_size);
2770  chunked_stream->buf_size++;
2771  chunked_stream->buf_pos--;
2772  if(req->contentLength == ~0u) req->contentLength = chunked_stream->chunk_size;
2773  else req->contentLength += chunked_stream->chunk_size;
2774  chunked_stream->state = CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE;
2775  }
2776  break;
2777 
2778  case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE:
2779  ch = next_chunked_data_char(chunked_stream);
2780  if(ch == '\n')
2781  chunked_stream->state = chunked_stream->chunk_size
2782  ? CHUNKED_STREAM_STATE_READING_CHUNK
2783  : CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END;
2784  else if(ch != '\r')
2785  WARN("unexpected char '%c'\n", ch);
2786  break;
2787 
2788  case CHUNKED_STREAM_STATE_READING_CHUNK:
2789  assert(chunked_stream->chunk_size);
2790  if(!size) {
2791  continue_read = FALSE;
2792  break;
2793  }
2794  read_bytes = min(size, chunked_stream->chunk_size);
2795 
2796  if(chunked_stream->buf_size) {
2797  if(read_bytes > chunked_stream->buf_size)
2798  read_bytes = chunked_stream->buf_size;
2799 
2800  memcpy(buf+ret_read, chunked_stream->buf+chunked_stream->buf_pos, read_bytes);
2801  chunked_stream->buf_pos += read_bytes;
2802  chunked_stream->buf_size -= read_bytes;
2803  }else {
2804  res = NETCON_recv(req->netconn, (char*)buf+ret_read, read_bytes,
2805  allow_blocking, (int*)&read_bytes);
2806  if(res != ERROR_SUCCESS) {
2807  continue_read = FALSE;
2808  break;
2809  }
2810 
2811  if(!read_bytes) {
2812  chunked_stream->state = CHUNKED_STREAM_STATE_ERROR;
2813  continue;
2814  }
2815  }
2816 
2817  chunked_stream->chunk_size -= read_bytes;
2818  size -= read_bytes;
2819  ret_read += read_bytes;
2820  if(!chunked_stream->chunk_size)
2821  chunked_stream->state = CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA;
2822  allow_blocking = FALSE;
2823  break;
2824 
2825  case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA:
2826  ch = next_chunked_data_char(chunked_stream);
2827  if(ch == '\n')
2828  chunked_stream->state = CHUNKED_STREAM_STATE_READING_CHUNK_SIZE;
2829  else if(ch != '\r')
2830  WARN("unexpected char '%c'\n", ch);
2831  break;
2832 
2833  case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END:
2834  ch = next_chunked_data_char(chunked_stream);
2835  if(ch == '\n')
2836  chunked_stream->state = CHUNKED_STREAM_STATE_END_OF_STREAM;
2837  else if(ch != '\r')
2838  WARN("unexpected char '%c'\n", ch);
2839  break;
2840 
2841  case CHUNKED_STREAM_STATE_END_OF_STREAM:
2842  case CHUNKED_STREAM_STATE_ERROR:
2843  continue_read = FALSE;
2844  break;
2845  }
2846  } while(continue_read);
2847 
2848  if(ret_read)
2849  res = ERROR_SUCCESS;
2850  if(res != ERROR_SUCCESS)
2851  return res;
2852 
2853  TRACE("read %d bytes\n", ret_read);
2854  *read = ret_read;
2855  return ERROR_SUCCESS;
2856 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
enum chunked_stream_t::@563 state
DWORD chunk_size
Definition: http.c:407
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
DWORD buf_pos
Definition: http.c:406
BYTE buf[READ_BUFFER_SIZE]
Definition: http.c:404
#define WARN(fmt,...)
Definition: debug.h:111
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define assert(x)
Definition: debug.h:53
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:169
DWORD NETCON_recv(netconn_t *, void *, size_t, BOOL, int *) DECLSPEC_HIDDEN
unsigned int BOOL
Definition: ntddk_ex.h:94
netconn_t * netconn
Definition: internet.h:352
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: parse.h:22
static char next_chunked_data_char(chunked_stream_t *stream)
Definition: http.c:2694
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD contentLength
Definition: internet.h:375
#define min(a, b)
Definition: monoChain.cc:55
DWORD buf_size
Definition: http.c:405
GLuint res
Definition: glext.h:9613
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

Referenced by chunked_drain_content().

◆ collect_connections()

BOOL collect_connections ( collect_type_t  collect_type)

Definition at line 313 of file http.c.

314 {
315  netconn_t *netconn, *netconn_safe;
316  server_t *server, *server_safe;
317  BOOL remaining = FALSE;
318  DWORD64 now;
319 
320 #ifdef __REACTOS__
321  now = GetTickCount();
322 #else
323  now = GetTickCount64();
324 #endif
325 
327  LIST_FOR_EACH_ENTRY_SAFE(netconn, netconn_safe, &server->conn_pool, netconn_t, pool_entry) {
328  if(collect_type > COLLECT_TIMEOUT || netconn->keep_until < now) {
329  TRACE("freeing %p\n", netconn);
330  list_remove(&netconn->pool_entry);
331  free_netconn(netconn);
332  }else {
333  remaining = TRUE;
334  }
335  }
336 
337  if(collect_type == COLLECT_CLEANUP) {
338  list_remove(&server->entry);
339  list_init(&server->entry);
341  }
342  }
343 
344  return remaining;
345 }
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
uint8_t entry
Definition: isohybrid.c:63
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
void server_release(server_t *server)
Definition: http.c:229
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
unsigned int BOOL
Definition: ntddk_ex.h:94
struct list pool_entry
Definition: internet.h:87
time_t now
Definition: finger.c:65
void free_netconn(netconn_t *) DECLSPEC_HIDDEN
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
uint64_t DWORD64
Definition: typedefs.h:65
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
ULONGLONG keep_until
static struct list connection_pool
Definition: http.c:221

Referenced by collect_connections_proc(), DllMain(), and INET_SetOption().

◆ collect_connections_proc()

static DWORD WINAPI collect_connections_proc ( void arg)
static

Definition at line 347 of file http.c.

348 {
349  BOOL remaining_conns;
350 
351  do {
352  /* FIXME: Use more sophisticated method */
353  Sleep(5000);
354 
356 
357  remaining_conns = collect_connections(COLLECT_TIMEOUT);
358  if(!remaining_conns)
360 
362  }while(remaining_conns);
363 
365 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode)
Definition: loader.c:514
HMODULE WININET_hModule
Definition: internet.c:77
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL collector_running
Definition: http.c:222
static CRITICAL_SECTION connection_pool_cs
Definition: http.c:212
BOOL collect_connections(collect_type_t collect_type)
Definition: http.c:313
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by http_release_netconn().

◆ commit_cache_entry()

static void commit_cache_entry ( http_request_t req)
static

Definition at line 2370 of file http.c.

2371 {
2372  WCHAR *header;
2373  DWORD header_len;
2374  BOOL res;
2375 
2376  TRACE("%p\n", req);
2377 
2378  CloseHandle(req->hCacheFile);
2379  req->hCacheFile = NULL;
2380 
2382  header_len = (header ? strlenW(header) : 0);
2385  header, header_len, NULL, 0);
2386  if(res)
2387  req->req_file->is_committed = TRUE;
2388  else
2389  WARN("CommitUrlCacheEntry failed: %u\n", GetLastError());
2390  heap_free(header);
2391 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
FILETIME last_modified
Definition: internet.h:367
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
FILETIME expires
Definition: internet.h:370
unsigned int BOOL
Definition: ntddk_ex.h:94
req_file_t * req_file
Definition: internet.h:369
smooth NULL
Definition: ftsmooth.c:416
#define NORMAL_CACHE_ENTRY
Definition: wininet.h:2086
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI CommitUrlCacheEntryW(LPCWSTR lpszUrlName, LPCWSTR lpszLocalFileName, FILETIME ExpireTime, FILETIME LastModifiedTime, DWORD CacheEntryType, LPWSTR lpHeaderInfo, DWORD dwHeaderSize, LPCWSTR lpszFileExtension, LPCWSTR lpszOriginalUrl)
Definition: urlcache.c:3096
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL is_committed
Definition: internet.h:253
HANDLE hCacheFile
Definition: internet.h:368
static WCHAR * build_response_header(http_request_t *request, BOOL use_cr)
Definition: http.c:710
GLuint res
Definition: glext.h:9613
WCHAR * file_name
Definition: internet.h:251
WCHAR * url
Definition: internet.h:252
struct CFHEADER header
Definition: fdi.c:109
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by create_cache_entry(), and read_http_stream().

◆ compose_request_url()

static WCHAR* compose_request_url ( http_request_t req)
static

Definition at line 1869 of file http.c.

1870 {
1871  static const WCHAR http[] = { 'h','t','t','p',':','/','/',0 };
1872  static const WCHAR https[] = { 'h','t','t','p','s',':','/','/',0 };
1873  const WCHAR *host, *scheme;
1874  WCHAR *buf, *ptr;
1875  size_t len;
1876 
1877  host = req->server->canon_host_port;
1878 
1879  if (req->server->is_https)
1880  scheme = https;
1881  else
1882  scheme = http;
1883 
1884  len = strlenW(scheme) + strlenW(host) + (req->path[0] != '/' ? 1 : 0) + strlenW(req->path);
1885  ptr = buf = heap_alloc((len+1) * sizeof(WCHAR));
1886  if(buf) {
1887  strcpyW(ptr, scheme);
1888  ptr += strlenW(ptr);
1889 
1890  strcpyW(ptr, host);
1891  ptr += strlenW(ptr);
1892 
1893  if(req->path[0] != '/')
1894  *ptr++ = '/';
1895 
1896  strcpyW(ptr, req->path);
1897  ptr += strlenW(ptr);
1898  *ptr = 0;
1899  }
1900 
1901  return buf;
1902 }
BOOL is_https
Definition: internet.h:39
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * host
Definition: whois.c:55
DWORD scheme
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * canon_host_port
Definition: internet.h:46
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
server_t * server
Definition: internet.h:348
static WCHAR http[]
Definition: url.c:30
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
LPWSTR path
Definition: internet.h:350

Referenced by create_cache_entry(), and HTTPREQ_QueryOption().

◆ convert_accept_types()

static WCHAR** convert_accept_types ( const char **  accept_types)
static

Definition at line 1416 of file http.c.

1417 {
1418  unsigned int count;
1419  const char **types = accept_types;
1420  WCHAR **typesW;
1421  BOOL invalid_pointer = FALSE;
1422 
1423  if (!types) return NULL;
1424  count = 0;
1425  while (*types)
1426  {
1427  __TRY
1428  {
1429  /* find out how many there are */
1430  if (*types && **types)
1431  {
1432  TRACE("accept type: %s\n", debugstr_a(*types));
1433  count++;
1434  }
1435  }
1437  {
1438  WARN("invalid accept type pointer\n");
1439  invalid_pointer = TRUE;
1440  }
1441  __ENDTRY;
1442  types++;
1443  }
1444  if (invalid_pointer) return NULL;
1445  if (!(typesW = heap_alloc( sizeof(WCHAR *) * (count + 1) ))) return NULL;
1446  count = 0;
1447  types = accept_types;
1448  while (*types)
1449  {
1450  if (*types && **types) typesW[count++] = heap_strdupAtoW( *types );
1451  types++;
1452  }
1453  typesW[count] = NULL;
1454  return typesW;
1455 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:111
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define __TRY
Definition: compat.h:70
static WCHAR * heap_strdupAtoW(const char *str)
Definition: appwiz.h:80
#define TRACE(s)
Definition: solgame.cpp:4
Definition: cmds.c:130
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define __ENDTRY
Definition: compat.h:72
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:71

Referenced by HttpOpenRequestA().

◆ create_cache_entry()

static void create_cache_entry ( http_request_t req)
static

Definition at line 2393 of file http.c.

2394 {
2395  static const WCHAR no_cacheW[] = {'n','o','-','c','a','c','h','e',0};
2396  static const WCHAR no_storeW[] = {'n','o','-','s','t','o','r','e',0};
2397 
2399  WCHAR *url;
2400  BOOL b = TRUE;
2401 
2402  /* FIXME: We should free previous cache file earlier */
2403  if(req->req_file) {
2404  req_file_release(req->req_file);
2405  req->req_file = NULL;
2406  }
2407  if(req->hCacheFile) {
2408  CloseHandle(req->hCacheFile);
2409  req->hCacheFile = NULL;
2410  }
2411 
2413  b = FALSE;
2414 
2415  if(b) {
2416  int header_idx;
2417 
2419 
2420  header_idx = HTTP_GetCustomHeaderIndex(req, szCache_Control, 0, FALSE);
2421  if(header_idx != -1) {
2422  WCHAR *ptr;
2423 
2424  for(ptr=req->custHeaders[header_idx].lpszValue; *ptr; ) {
2425  WCHAR *end;
2426 
2427  while(*ptr==' ' || *ptr=='\t')
2428  ptr++;
2429 
2430  end = strchrW(ptr, ',');
2431  if(!end)
2432  end = ptr + strlenW(ptr);
2433 
2434  if(!strncmpiW(ptr, no_cacheW, sizeof(no_cacheW)/sizeof(*no_cacheW)-1)
2435  || !strncmpiW(ptr, no_storeW, sizeof(no_storeW)/sizeof(*no_storeW)-1)) {
2436  b = FALSE;
2437  break;
2438  }
2439 
2440  ptr = end;
2441  if(*ptr == ',')
2442  ptr++;
2443  }
2444  }
2445 
2447  }
2448 
2449  if(!b) {
2450  if(!(req->hdr.dwFlags & INTERNET_FLAG_NEED_FILE))
2451  return;
2452 
2453  FIXME("INTERNET_FLAG_NEED_FILE is not supported correctly\n");
2454  }
2455 
2456  url = compose_request_url(req);
2457  if(!url) {
2458  WARN("Could not get URL\n");
2459  return;
2460  }
2461 
2462  b = CreateUrlCacheEntryW(url, req->contentLength == ~0u ? 0 : req->contentLength, NULL, file_name, 0);
2463  if(!b) {
2464  WARN("Could not create cache entry: %08x\n", GetLastError());
2465  return;
2466  }
2467 
2469  req->req_file->url = url;
2470 
2473  if(req->hCacheFile == INVALID_HANDLE_VALUE) {
2474  WARN("Could not create file: %u\n", GetLastError());
2475  req->hCacheFile = NULL;
2476  return;
2477  }
2478 
2479  if(req->read_size) {
2480  DWORD written;
2481 
2482  b = WriteFile(req->hCacheFile, req->read_buf+req->read_pos, req->read_size, &written, NULL);
2483  if(!b)
2484  FIXME("WriteFile failed: %u\n", GetLastError());
2485 
2486  if(req->data_stream->vtbl->end_of_data(req->data_stream, req))
2487  commit_cache_entry(req);
2488  }
2489 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
BOOL WINAPI CreateUrlCacheEntryW(LPCWSTR lpszUrlName, DWORD dwExpectedFileSize, LPCWSTR lpszFileExtension, LPWSTR lpszFileName, DWORD dwReserved)
Definition: urlcache.c:2826
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define INTERNET_FLAG_NO_CACHE_WRITE
Definition: wininet.h:66
void req_file_release(req_file_t *req_file)
Definition: internet.c:3901
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define INTERNET_FLAG_NEED_FILE
Definition: wininet.h:88
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define WARN(fmt,...)
Definition: debug.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint GLuint end
Definition: gl.h:1545
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
BOOL(* end_of_data)(data_stream_t *, http_request_t *)
Definition: http.c:395
#define FILE_SHARE_READ
Definition: compat.h:125
HTTPHEADERW * custHeaders
Definition: internet.h:364
static const WCHAR szCache_Control[]
Definition: http.c:85
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define FIXME(fmt,...)
Definition: debug.h:110
req_file_t * req_file
Definition: internet.h:369
static PVOID ptr
Definition: dispmode.c:27
object_header_t hdr
Definition: internet.h:346
smooth NULL
Definition: ftsmooth.c:416
DWORD create_req_file(const WCHAR *file_name, req_file_t **ret)
Definition: internet.c:3874
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
data_stream_t * data_stream
Definition: internet.h:381
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR url[]
Definition: encode.c:1432
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD read_size
Definition: internet.h:378
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
const data_stream_vtbl_t * vtbl
Definition: internet.h:333
static INT HTTP_GetCustomHeaderIndex(http_request_t *req, LPCWSTR lpszField, INT index, BOOL Request)
HANDLE hCacheFile
Definition: internet.h:368
DWORD contentLength
Definition: internet.h:375
#define CREATE_ALWAYS
Definition: disk.h:72
DWORD read_pos
Definition: internet.h:377
BYTE read_buf[READ_BUFFER_SIZE]
Definition: internet.h:379
static LPCWSTR file_name
Definition: protocol.c:146
#define CreateFileW
Definition: compat.h:400
static void commit_cache_entry(http_request_t *req)
Definition: http.c:2370
LPWSTR lpszValue
Definition: internet.h:322
WCHAR * url
Definition: internet.h:252
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static WCHAR * compose_request_url(http_request_t *req)
Definition: http.c:1869
CRITICAL_SECTION headers_section
Definition: internet.h:363

Referenced by HTTP_HttpEndRequestW(), and HTTP_HttpSendRequestW().

◆ destroy_authinfo()

static void destroy_authinfo ( struct HttpAuthInfo authinfo)
static

Definition at line 864 of file http.c.

865 {
866  if (!authinfo) return;
867 
872 
873  heap_free(authinfo->auth_data);
876 }
#define SecIsValidHandle(x)
Definition: sspi.h:63
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
CredHandle cred
DWORD scheme
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
CtxtHandle ctx

Referenced by HTTP_DoAuthorization(), HTTP_HttpSendRequestW(), and HTTPREQ_Destroy().

◆ destroy_data_stream()

static void destroy_data_stream ( data_stream_t stream)
inlinestatic

Definition at line 420 of file http.c.

421 {
422  stream->vtbl->destroy(stream);
423 }
Definition: parse.h:22

Referenced by HTTPREQ_Destroy(), and reset_data_stream().

◆ drain_content()

static DWORD drain_content ( http_request_t req,
BOOL  blocking 
)
static

Definition at line 3039 of file http.c.

3040 {
3041  DWORD res;
3042 
3043  TRACE("%p\n", req->netconn);
3044 
3045  if(!is_valid_netconn(req->netconn))
3046  return ERROR_NO_DATA;
3047 
3048  if(!strcmpW(req->verb, szHEAD))
3049  return ERROR_SUCCESS;
3050 
3052  res = req->data_stream->vtbl->drain_content(req->data_stream, req, blocking);
3054  return res;
3055 }
static const WCHAR szHEAD[]
Definition: http.c:76
#define ERROR_SUCCESS
Definition: deptool.c:10
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
netconn_t * netconn
Definition: internet.h:352
data_stream_t * data_stream
Definition: internet.h:381
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR verb
Definition: internet.h:351
#define ERROR_NO_DATA
Definition: winerror.h:284
DWORD(* drain_content)(data_stream_t *, http_request_t *, BOOL)
Definition: http.c:397
unsigned long DWORD
Definition: ntddk_ex.h:95
const data_stream_vtbl_t * vtbl
Definition: internet.h:333
BOOL is_valid_netconn(netconn_t *) DECLSPEC_HIDDEN
CRITICAL_SECTION read_section
Definition: internet.h:374
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
GLuint res
Definition: glext.h:9613
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by async_read_file_proc(), HTTP_HttpEndRequestW(), HTTP_HttpSendRequestW(), HTTPREQ_CloseConnection(), HTTPREQ_Read(), and open_http_connection().

◆ encode_auth_data()

static WCHAR* encode_auth_data ( const WCHAR scheme,
const char data,
UINT  data_len 
)
static

Definition at line 1631 of file http.c.

1632 {
1633  WCHAR *ret;
1634  UINT len, scheme_len = strlenW( scheme );
1635 
1636  /* scheme + space + base64 encoded data (3/2/1 bytes data -> 4 bytes of characters) */
1637  len = scheme_len + 1 + ((data_len + 2) * 4) / 3;
1638  if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1639  memcpy( ret, scheme, scheme_len * sizeof(WCHAR) );
1640  ret[scheme_len] = ' ';
1641  HTTP_EncodeBase64( data, data_len, ret + scheme_len + 1 );
1642  return ret;
1643 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
DWORD scheme
static UINT HTTP_EncodeBase64(LPCSTR bin, unsigned int len, LPWSTR base64)
Definition: http.c:1525
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50

Referenced by HTTP_InsertAuthorization().

◆ end_of_read_data()

static BOOL end_of_read_data ( http_request_t req)
static

Definition at line 2572 of file http.c.

2573 {
2574  return !req->read_size && req->data_stream->vtbl->end_of_data(req->data_stream, req);
2575 }
BOOL(* end_of_data)(data_stream_t *, http_request_t *)
Definition: http.c:395
data_stream_t * data_stream
Definition: internet.h:381
DWORD read_size
Definition: internet.h:378
const data_stream_vtbl_t * vtbl
Definition: internet.h:333

Referenced by HTTPREQ_QueryDataAvailable(), and HTTPREQ_ReadFile().

◆ free_accept_types()

static void free_accept_types ( WCHAR **  accept_types)
static

Definition at line 1403 of file http.c.

1404 {
1405  WCHAR *ptr, **types = accept_types;
1406 
1407  if (!types) return;
1408  while ((ptr = *types))
1409  {
1410  heap_free( ptr );
1411  types++;
1412  }
1413  heap_free( accept_types );
1414 }
static PVOID ptr
Definition: dispmode.c:27
Definition: cmds.c:130
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HttpOpenRequestA().

◆ get_host_header()

static WCHAR* get_host_header ( http_request_t req)
static

Definition at line 382 of file http.c.

383 {
385  WCHAR *ret = NULL;
386 
388  if ((header = HTTP_GetHeader( req, hostW ))) ret = heap_strdupW( header->lpszValue );
389  else ret = heap_strdupW( req->server->canon_host_port );
391  return ret;
392 }
static const WCHAR hostW[]
Definition: http.c:70
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
const WCHAR * canon_host_port
Definition: internet.h:46
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
static LPHTTPHEADERW HTTP_GetHeader(http_request_t *req, LPCWSTR head)
Definition: http.c:372
server_t * server
Definition: internet.h:348
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION headers_section
Definition: internet.h:363
struct CFHEADER header
Definition: fdi.c:109

Referenced by HTTP_InsertAuthorization().

◆ get_redirect_url()

static WCHAR* get_redirect_url ( http_request_t request)
static

Definition at line 4013 of file http.c.

4014 {
4015  static WCHAR szHttp[] = {'h','t','t','p',0};
4016  static WCHAR szHttps[] = {'h','t','t','p','s',0};
4017  http_session_t *session = request->session;
4018  URL_COMPONENTSW urlComponents = { sizeof(urlComponents) };
4019  WCHAR *orig_url = NULL, *redirect_url = NULL, *combined_url = NULL;
4020  DWORD url_length = 0, res;
4021  BOOL b;
4022 
4023  url_length = 0;
4024  res = HTTP_HttpQueryInfoW(request, HTTP_QUERY_LOCATION, redirect_url, &url_length, NULL);
4026  redirect_url = heap_alloc(url_length);
4027  res = HTTP_HttpQueryInfoW(request, HTTP_QUERY_LOCATION, redirect_url, &url_length, NULL);
4028  }
4029  if(res != ERROR_SUCCESS) {
4030  heap_free(redirect_url);
4031  return NULL;
4032  }
4033 
4034  urlComponents.dwSchemeLength = 1;
4035  b = InternetCrackUrlW(redirect_url, url_length / sizeof(WCHAR), 0, &urlComponents);
4036  if(b && urlComponents.dwSchemeLength &&
4037  urlComponents.nScheme != INTERNET_SCHEME_HTTP && urlComponents.nScheme != INTERNET_SCHEME_HTTPS) {
4038  TRACE("redirect to non-http URL\n");
4039  return NULL;
4040  }
4041 
4042  urlComponents.lpszScheme = (request->hdr.dwFlags & INTERNET_FLAG_SECURE) ? szHttps : szHttp;
4043  urlComponents.dwSchemeLength = 0;
4044  urlComponents.lpszHostName = request->server->name;
4045  urlComponents.nPort = request->server->port;
4046  urlComponents.lpszUserName = session->userName;
4047  urlComponents.lpszUrlPath = request->path;
4048 
4049  b = InternetCreateUrlW(&urlComponents, 0, NULL, &url_length);
4051  orig_url = heap_alloc(url_length);
4052 
4053  /* convert from bytes to characters */
4054  url_length = url_length / sizeof(WCHAR) - 1;
4055  b = InternetCreateUrlW(&urlComponents, 0, orig_url, &url_length);
4056  }
4057 
4058  if(b) {
4059  url_length = 0;
4060  b = InternetCombineUrlW(orig_url, redirect_url, NULL, &url_length, ICU_ENCODE_SPACES_ONLY);
4062  combined_url = heap_alloc(url_length * sizeof(WCHAR));
4063  b = InternetCombineUrlW(orig_url, redirect_url, combined_url, &url_length, ICU_ENCODE_SPACES_ONLY);
4064  if(!b) {
4066  combined_url = NULL;
4067  }
4068  }
4069  }
4070 
4071  heap_free(orig_url);
4072  heap_free(redirect_url);
4073  return combined_url;
4074 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define INTERNET_FLAG_SECURE
Definition: wininet.h:71
LPWSTR userName
Definition: internet.h:307
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LPWSTR lpszHostName
Definition: wininet.h:215
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
DWORD dwSchemeLength
Definition: wininet.h:213
INTERNET_PORT nPort
Definition: wininet.h:217
unsigned int BOOL
Definition: ntddk_ex.h:94
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
static DWORD HTTP_HttpQueryInfoW(http_request_t *, DWORD, LPVOID, LPDWORD, LPDWORD)
Definition: http.c:3544
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
#define ICU_ENCODE_SPACES_ONLY
Definition: winhttp.h:293
LPWSTR lpszScheme
Definition: wininet.h:212
__wchar_t WCHAR
Definition: xmlstorage.h:180
INTERNET_SCHEME nScheme
Definition: wininet.h:214
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI InternetCombineUrlW(LPCWSTR lpszBaseUrl, LPCWSTR lpszRelativeUrl, LPWSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:4033
LPWSTR lpszUserName
Definition: wininet.h:218
LPWSTR lpszUrlPath
Definition: wininet.h:222
BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags, LPWSTR lpszUrl, LPDWORD lpdwUrlLength)
Definition: internet.c:4310
const char * combined_url
Definition: protocol.c:466
Definition: tftpd.h:85
BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwFlags, URL_COMPONENTSW *lpUC)
Definition: internet.c:1645
GLuint res
Definition: glext.h:9613
#define HTTP_QUERY_LOCATION
Definition: wininet.h:1556
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by HTTP_HttpEndRequestW(), and HTTP_HttpSendRequestW().

◆ get_server()

server_t* get_server ( substr_t  name,
INTERNET_PORT  port,
BOOL  is_https,
BOOL  do_create 
)

Definition at line 276 of file http.c.

277 {
278  server_t *iter, *server = NULL;
279 
281 
283  if(iter->port == port && name.len == strlenW(iter->name) && !strncmpiW(iter->name, name.str, name.len)
284  && iter->is_https == is_https) {
285  server = iter;
287  break;
288  }
289  }
290 
291  if(!server && do_create) {
292  server = heap_alloc_zero(sizeof(*server));
293  if(server) {
294  server->ref = 2; /* list reference and return */
295  server->port = port;
296  server->is_https = is_https;
297  list_init(&server->conn_pool);
298  server->name = heap_strndupW(name.str, name.len);
299  if(server->name && process_host_port(server)) {
301  }else {
302  heap_free(server);
303  server = NULL;
304  }
305  }
306  }
307 
309 
310  return server;
311 }
static BOOL process_host_port(server_t *server)
Definition: http.c:249
BOOL is_https
Definition: internet.h:39
static LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
static rfbScreenInfoPtr server
Definition: vnc.c:74
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
uint8_t entry
Definition: isohybrid.c:63
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
INTERNET_PORT port
Definition: internet.h:38
smooth NULL
Definition: ftsmooth.c:416
static CRITICAL_SECTION connection_pool_cs
Definition: http.c:212
void server_addref(server_t *server)
Definition: http.c:224
WCHAR * name
Definition: internet.h:37
Definition: name.c:36
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
USHORT port
Definition: uri.c:227
static struct list connection_pool
Definition: http.c:221
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HTTP_DealWithProxy(), HTTP_HandleRedirect(), and HTTP_HttpOpenRequestW().

◆ HTTP_build_req()

static LPWSTR HTTP_build_req ( LPCWSTR list,
int  len 
)
static

Definition at line 4194 of file http.c.

4195 {
4196  LPCWSTR *t;
4197  LPWSTR str;
4198 
4199  for( t = list; *t ; t++ )
4200  len += strlenW( *t );
4201  len++;
4202 
4203  str = heap_alloc(len*sizeof(WCHAR));
4204  *str = 0;
4205 
4206  for( t = list; *t ; t++ )
4207  strcatW( str, *t );
4208 
4209  return str;
4210 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
GLdouble GLdouble t
Definition: gl.h:2047
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
Definition: _list.h:228
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by build_request_header(), and build_response_header().

◆ HTTP_clear_response_headers()

static void HTTP_clear_response_headers ( http_request_t request)
static

Definition at line 5872 of file http.c.

5873 {
5874  DWORD i;
5875 
5876  EnterCriticalSection( &request->headers_section );
5877 
5878  for( i=0; i<request->nCustHeaders; i++)
5879  {
5880  if( !request->custHeaders[i].lpszField )
5881  continue;
5882  if( !request->custHeaders[i].lpszValue )
5883  continue;
5884  if ( request->custHeaders[i].wFlags & HDR_ISREQUEST )
5885  continue;
5887  i--;
5888  }
5889 
5890  LeaveCriticalSection( &request->headers_section );
5891 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define HDR_ISREQUEST
Definition: internet.h:315
static BOOL HTTP_DeleteCustomHeader(http_request_t *req, DWORD index)
Definition: http.c:6293
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: tftpd.h:85
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by HTTP_GetResponseHeaders().

◆ HTTP_Connect()

DWORD HTTP_Connect ( appinfo_t hIC,
LPCWSTR  lpszServerName,
INTERNET_PORT  serverPort,
LPCWSTR  lpszUserName,
LPCWSTR  lpszPassword,
DWORD  dwFlags,
DWORD_PTR  dwContext,
DWORD  dwInternalFlags,
HINTERNET ret 
)

Definition at line 5806 of file http.c.

5810 {
5811  http_session_t *session = NULL;
5812 
5813  TRACE("-->\n");
5814 
5815  if (!lpszServerName || !lpszServerName[0])
5816  return ERROR_INVALID_PARAMETER;
5817 
5818  assert( hIC->hdr.htype == WH_HINIT );
5819 
5820  session = alloc_object(&hIC->hdr, &HTTPSESSIONVtbl, sizeof(http_session_t));
5821  if (!session)
5822  return ERROR_OUTOFMEMORY;
5823 
5824  /*
5825  * According to my tests. The name is not resolved until a request is sent
5826  */
5827 
5828  session->hdr.htype = WH_HHTTPSESSION;
5829  session->hdr.dwFlags = dwFlags;
5830  session->hdr.dwContext = dwContext;
5831  session->hdr.dwInternalFlags |= dwInternalFlags;
5832  session->hdr.decoding = hIC->hdr.decoding;
5833 
5834  WININET_AddRef( &hIC->hdr );
5835  session->appInfo = hIC;
5836  list_add_head( &hIC->hdr.children, &session->hdr.entry );
5837 
5838  session->hostName = heap_strdupW(lpszServerName);
5839  if (lpszUserName && lpszUserName[0])
5840  session->userName = heap_strdupW(lpszUserName);
5841  if (lpszPassword && lpszPassword[0])
5842  session->password = heap_strdupW(lpszPassword);
5843  session->hostPort = serverPort;
5844  session->connect_timeout = hIC->connect_timeout;
5845  session->send_timeout = 0;
5846  session->receive_timeout = 0;
5847 
5848  /* Don't send a handle created callback if this handle was created with InternetOpenUrl */
5849  if (!(session->hdr.dwInternalFlags & INET_OPENURL))
5850  {
5851  INTERNET_SendCallback(&hIC->hdr, dwContext,
5853  sizeof(HINTERNET));
5854  }
5855 
5856 /*
5857  * an INTERNET_STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on
5858  * windows
5859  */
5860 
5861  TRACE("%p --> %p\n", hIC, session);
5862 
5863  *ret = session->hdr.hInternet;
5864  return ERROR_SUCCESS;
5865 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
INTERNET_PORT hostPort
Definition: internet.h:309
DWORD connect_timeout
Definition: internet.h:310
LPWSTR userName
Definition: internet.h:307
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
struct list children
#define assert(x)
Definition: debug.h:53
_In_opt_ LPSTR _In_opt_ LPSTR lpszPassword
Definition: winbase.h:2651
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
DWORD_PTR dwContext
Definition: internet.h:279
LPWSTR hostName
Definition: internet.h:306
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
DWORD receive_timeout
Definition: internet.h:312
appinfo_t * appInfo
Definition: internet.h:305
smooth NULL
Definition: ftsmooth.c:416
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:178
#define TRACE(s)
Definition: solgame.cpp:4
DWORD send_timeout
Definition: internet.h:311
object_header_t hdr
Definition: internet.h:304
struct list entry
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
void * alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t size)
Definition: internet.c:112
DWORD connect_timeout
Definition: internet.h:299
HINTERNET hInternet
Definition: internet.h:276
static const object_vtbl_t HTTPSESSIONVtbl
Definition: http.c:5784
object_header_t hdr
Definition: internet.h:292
DWORD dwInternalFlags
Definition: internet.h:282
#define INET_OPENURL
Definition: internet.h:244
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
LPWSTR password
Definition: internet.h:308
WH_TYPE htype
Definition: internet.h:274
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by INTERNET_InternetOpenUrlW(), and InternetConnectW().

◆ HTTP_DealWithProxy()

static BOOL HTTP_DealWithProxy ( appinfo_t hIC,
http_session_t session,
http_request_t request 
)
static

Definition at line 1800 of file http.c.

1801 {
1802  static const WCHAR protoHttp[] = { 'h','t','t','p',0 };
1803  static const WCHAR szHttp[] = { 'h','t','t','p',':','/','/',0 };
1804  static WCHAR szNul[] = { 0 };
1805  URL_COMPONENTSW UrlComponents = { sizeof(UrlComponents) };
1806  server_t *new_server = NULL;
1807  WCHAR *proxy;
1808 
1809  proxy = INTERNET_FindProxyForProtocol(hIC->proxy, protoHttp);
1810  if(!proxy)
1811  return FALSE;
1813  proxy, strlenW(szHttp), szHttp, strlenW(szHttp))) {
1814  WCHAR *proxy_url = heap_alloc(strlenW(proxy)*sizeof(WCHAR) + sizeof(szHttp));
1815  if(!proxy_url) {
1816  heap_free(proxy);
1817  return FALSE;
1818  }
1819  strcpyW(proxy_url, szHttp);
1820  strcatW(proxy_url, proxy);
1821  heap_free(proxy);
1822  proxy = proxy_url;
1823  }
1824 
1825  UrlComponents.dwHostNameLength = 1;
1826  if(InternetCrackUrlW(proxy, 0, 0, &UrlComponents) && UrlComponents.dwHostNameLength) {
1827  if( !request->path )
1828  request->path = szNul;
1829 
1830  new_server = get_server(substr(UrlComponents.lpszHostName, UrlComponents.dwHostNameLength),
1831  UrlComponents.nPort, UrlComponents.nScheme == INTERNET_SCHEME_HTTPS, TRUE);
1832  }
1833  heap_free(proxy);
1834  if(!new_server)
1835  return FALSE;
1836 
1837  request->proxy = new_server;
1838 
1839  TRACE("proxy server=%s port=%d\n", debugstr_w(new_server->name), new_server->port);
1840  return TRUE;
1841 }
int proxy
Definition: main.c:67
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define NORM_IGNORECASE
Definition: winnls.h:173
LPWSTR lpszHostName
Definition: wininet.h:215
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
INTERNET_PORT port
Definition: internet.h:38
INTERNET_PORT nPort
Definition: wininet.h:217
#define debugstr_w
Definition: kernel32.h:32
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2275
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
INTERNET_SCHEME nScheme
Definition: wininet.h:214
#define LOCALE_SYSTEM_DEFAULT
DWORD dwHostNameLength
Definition: wininet.h:216
LPWSTR proxy
Definition: internet.h:294
WCHAR * name
Definition: internet.h:37
#define CSTR_EQUAL
Definition: winnls.h:453
server_t * get_server(substr_t name, INTERNET_PORT port, BOOL is_https, BOOL do_create)
Definition: http.c:276
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
Definition: tftpd.h:85
BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwFlags, URL_COMPONENTSW *lpUC)
Definition: internet.c:1645
static substr_t substr(const WCHAR *str, size_t len)
Definition: internet.h:204
WCHAR * INTERNET_FindProxyForProtocol(LPCWSTR szProxy, LPCWSTR proto)
Definition: internet.c:393
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HTTP_HttpOpenRequestW().

◆ HTTP_DecodeBase64()

static UINT HTTP_DecodeBase64 ( LPCWSTR  base64,
LPSTR  bin 
)
static

Definition at line 1581 of file http.c.

1582 {
1583  unsigned int n = 0;
1584 
1585  while(*base64)
1586  {
1587  signed char in[4];
1588 
1589  if (base64[0] >= ARRAYSIZE(HTTP_Base64Dec) ||
1590  ((in[0] = HTTP_Base64Dec[base64[0]]) == -1) ||
1591  base64[1] >= ARRAYSIZE(HTTP_Base64Dec) ||
1592  ((in[1] = HTTP_Base64Dec[base64[1]]) == -1))
1593  {
1594  WARN("invalid base64: %s\n", debugstr_w(base64));
1595  return 0;
1596  }
1597  if (bin)
1598  bin[n] = (unsigned char) (in[0] << 2 | in[1] >> 4);
1599  n++;
1600 
1601  if ((base64[2] == '=') && (base64[3] == '='))
1602  break;
1603  if (base64[2] > ARRAYSIZE(HTTP_Base64Dec) ||
1604  ((in[2] = HTTP_Base64Dec[base64[2]]) == -1))
1605  {
1606  WARN("invalid base64: %s\n", debugstr_w(&base64[2]));
1607  return 0;
1608  }
1609  if (bin)
1610  bin[n] = (unsigned char) (in[1] << 4 | in[2] >> 2);
1611  n++;
1612 
1613  if (base64[3] == '=')
1614  break;
1615  if (base64[3] > ARRAYSIZE(HTTP_Base64Dec) ||
1616  ((in[3] = HTTP_Base64Dec[base64[3]]) == -1))
1617  {
1618  WARN("invalid base64: %s\n", debugstr_w(&base64[3]));
1619  return 0;
1620  }
1621  if (bin)
1622  bin[n] = (unsigned char) (((in[2] << 6) & 0xc0) | in[3]);
1623  n++;
1624 
1625  base64 += 4;
1626  }
1627 
1628  return n;
1629 }
#define WARN(fmt,...)
Definition: debug.h:111
GLdouble n
Definition: glext.h:7729
#define debugstr_w
Definition: kernel32.h:32
unsigned char
Definition: typeof.h:29
#define ARRAYSIZE(array)
Definition: http.c:149
GLuint in
Definition: glext.h:9616
static struct _PeImage bin
static const signed char HTTP_Base64Dec[]
Definition: http.c:1566

Referenced by HTTP_DoAuthorization().

◆ HTTP_DeleteCustomHeader()

static BOOL HTTP_DeleteCustomHeader ( http_request_t req,
DWORD  index 
)
static

Definition at line 6293 of file http.c.

6294 {
6295  if( request->nCustHeaders <= 0 )
6296  return FALSE;
6297  if( index >= request->nCustHeaders )
6298  return FALSE;
6299  request->nCustHeaders--;
6300 
6301  heap_free(request->custHeaders[index].lpszField);
6302  heap_free(request->custHeaders[index].lpszValue);
6303 
6304  memmove( &request->custHeaders[index], &request->custHeaders[index+1],
6305  (request->nCustHeaders - index)* sizeof(HTTPHEADERW) );
6306  memset( &request->custHeaders[request->nCustHeaders], 0, sizeof(HTTPHEADERW) );
6307 
6308  return TRUE;
6309 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
GLuint index
Definition: glext.h:6031
Definition: tftpd.h:85
#define memset(x, y, z)
Definition: compat.h:39
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HTTP_clear_response_headers(), HTTP_ProcessHeader(), remove_header(), and set_content_length().

◆ HTTP_DoAuthorization()

static BOOL HTTP_DoAuthorization ( http_request_t request,
LPCWSTR  pszAuthValue,
struct HttpAuthInfo **  ppAuthInfo,
LPWSTR  domain_and_username,
LPWSTR  password,
LPWSTR  host 
)
static

Definition at line 1030 of file http.c.

1034 {
1035  SECURITY_STATUS sec_status;
1036  struct HttpAuthInfo *pAuthInfo = *ppAuthInfo;
1037  BOOL first = FALSE;
1038  LPWSTR szRealm = NULL;
1039 
1040  TRACE("%s\n", debugstr_w(pszAuthValue));
1041 
1042  if (!pAuthInfo)
1043  {
1044  TimeStamp exp;
1045 
1046  first = TRUE;
1047  pAuthInfo = heap_alloc(sizeof(*pAuthInfo));
1048  if (!pAuthInfo)
1049  return FALSE;
1050 
1051  SecInvalidateHandle(&pAuthInfo->cred);
1052  SecInvalidateHandle(&pAuthInfo->ctx);
1053  memset(&pAuthInfo->exp, 0, sizeof(pAuthInfo->exp));
1054  pAuthInfo->attr = 0;
1055  pAuthInfo->auth_data = NULL;
1056  pAuthInfo->auth_data_len = 0;
1057  pAuthInfo->finished = FALSE;
1058 
1059  if (is_basic_auth_value(pszAuthValue,NULL))
1060  {
1061  static const WCHAR szBasic[] = {'B','a','s','i','c',0};
1062  pAuthInfo->scheme = heap_strdupW(szBasic);
1063  if (!pAuthInfo->scheme)
1064  {
1065  heap_free(pAuthInfo);
1066  return FALSE;
1067  }
1068  }
1069  else
1070  {
1071  PVOID pAuthData;
1072  SEC_WINNT_AUTH_IDENTITY_W nt_auth_identity;
1073 
1074  pAuthInfo->scheme = heap_strdupW(pszAuthValue);
1075  if (!pAuthInfo->scheme)
1076  {
1077  heap_free(pAuthInfo);
1078  return FALSE;
1079  }
1080 
1081  if (domain_and_username)
1082  {
1083  WCHAR *user = strchrW(domain_and_username, '\\');
1084  WCHAR *domain = domain_and_username;
1085 
1086  /* FIXME: make sure scheme accepts SEC_WINNT_AUTH_IDENTITY before calling AcquireCredentialsHandle */
1087 
1088  pAuthData = &nt_auth_identity;
1089 
1090  if (user) user++;
1091  else
1092  {
1093  user = domain_and_username;
1094  domain = NULL;
1095  }
1096 
1097  nt_auth_identity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
1098  nt_auth_identity.User = user;
1099  nt_auth_identity.UserLength = strlenW(nt_auth_identity.User);
1100  nt_auth_identity.Domain = domain;
1101  nt_auth_identity.DomainLength = domain ? user - domain - 1 : 0;
1102  nt_auth_identity.Password = password;
1103  nt_auth_identity.PasswordLength = strlenW(nt_auth_identity.Password);
1104 
1105  cache_authorization(host, pAuthInfo->scheme, &nt_auth_identity);
1106  }
1107  else if(retrieve_cached_authorization(host, pAuthInfo->scheme, &nt_auth_identity))
1108  pAuthData = &nt_auth_identity;
1109  else
1110  /* use default credentials */
1111  pAuthData = NULL;
1112 
1113  sec_status = AcquireCredentialsHandleW(NULL, pAuthInfo->scheme,
1115  pAuthData, NULL,
1116  NULL, &pAuthInfo->cred,
1117  &exp);
1118 
1119  if(pAuthData && !domain_and_username) {
1120  heap_free(nt_auth_identity.User);
1121  heap_free(nt_auth_identity.Domain);
1122  heap_free(nt_auth_identity.Password);
1123  }
1124 
1125  if (sec_status == SEC_E_OK)
1126  {
1127  PSecPkgInfoW sec_pkg_info;
1128  sec_status = QuerySecurityPackageInfoW(pAuthInfo->scheme, &sec_pkg_info);
1129  if (sec_status == SEC_E_OK)
1130  {
1131  pAuthInfo->max_token = sec_pkg_info->cbMaxToken;
1132  FreeContextBuffer(sec_pkg_info);
1133  }
1134  }
1135  if (sec_status != SEC_E_OK)
1136  {
1137  WARN("AcquireCredentialsHandleW for scheme %s failed with error 0x%08x\n",
1138  debugstr_w(pAuthInfo->scheme), sec_status);
1139  heap_free(pAuthInfo->scheme);
1140  heap_free(pAuthInfo);
1141  return FALSE;
1142  }
1143  }
1144  *ppAuthInfo = pAuthInfo;
1145  }
1146  else if (pAuthInfo->finished)
1147  return FALSE;
1148 
1149  if ((strlenW(pszAuthValue) < strlenW(pAuthInfo->scheme)) ||
1150  strncmpiW(pszAuthValue, pAuthInfo->scheme, strlenW(pAuthInfo->scheme)))
1151  {
1152  ERR("authentication scheme changed from %s to %s\n",
1153  debugstr_w(pAuthInfo->scheme), debugstr_w(pszAuthValue));
1154  return FALSE;
1155  }
1156 
1157  if (is_basic_auth_value(pszAuthValue,&szRealm))
1158  {
1159  int userlen;
1160  int passlen;
1161  char *auth_data = NULL;
1162  UINT auth_data_len = 0;
1163 
1164  TRACE("basic authentication realm %s\n",debugstr_w(szRealm));
1165 
1166  if (!domain_and_username)
1167  {
1168  if (host && szRealm)
1170  if (auth_data_len == 0)
1171  {
1172  heap_free(szRealm);
1173  return FALSE;
1174  }
1175  }
1176  else
1177  {
1178  userlen = WideCharToMultiByte(CP_UTF8, 0, domain_and_username, lstrlenW(domain_and_username), NULL, 0, NULL, NULL);
1180 
1181  /* length includes a nul terminator, which will be re-used for the ':' */
1182  auth_data = heap_alloc(userlen + 1 + passlen);
1183  if (!auth_data)
1184  {
1185  heap_free(szRealm);
1186  return FALSE;
1187  }
1188 
1189  WideCharToMultiByte(CP_UTF8, 0, domain_and_username, -1, auth_data, userlen, NULL, NULL);
1190  auth_data[userlen] = ':';
1191  WideCharToMultiByte(CP_UTF8, 0, password, -1, &auth_data[userlen+1], passlen, NULL, NULL);
1192  auth_data_len = userlen + 1 + passlen;
1193  if (host && szRealm)
1195  }
1196 
1197  pAuthInfo->auth_data = auth_data;
1198  pAuthInfo->auth_data_len = auth_data_len;
1199  pAuthInfo->finished = TRUE;
1200  heap_free(szRealm);
1201  return TRUE;
1202  }
1203  else
1204  {
1205  LPCWSTR pszAuthData;
1206  SecBufferDesc out_desc, in_desc;
1207  SecBuffer out, in;
1208  unsigned char *buffer;
1211 
1212  in.BufferType = SECBUFFER_TOKEN;
1213  in.cbBuffer = 0;
1214  in.pvBuffer = NULL;
1215 
1216  in_desc.ulVersion = 0;
1217  in_desc.cBuffers = 1;
1218  in_desc.pBuffers = &in;
1219 
1220  pszAuthData = pszAuthValue + strlenW(pAuthInfo->scheme);
1221  if (*pszAuthData == ' ')
1222  {
1223  pszAuthData++;
1224  in.cbBuffer = HTTP_DecodeBase64(pszAuthData, NULL);
1225  in.pvBuffer = heap_alloc(in.cbBuffer);
1226  HTTP_DecodeBase64(pszAuthData, in.pvBuffer);
1227  }
1228 
1229  buffer = heap_alloc(pAuthInfo->max_token);
1230 
1231  out.BufferType = SECBUFFER_TOKEN;
1232  out.cbBuffer = pAuthInfo->max_token;
1233  out.pvBuffer = buffer;
1234 
1235  out_desc.ulVersion = 0;
1236  out_desc.cBuffers = 1;
1237  out_desc.pBuffers = &out;
1238 
1239  sec_status = InitializeSecurityContextW(first ? &pAuthInfo->cred : NULL,
1240  first ? NULL : &pAuthInfo->ctx,
1241  first ? request->server->name : NULL,
1242  context_req, 0, SECURITY_NETWORK_DREP,
1243  in.pvBuffer ? &in_desc : NULL,
1244  0, &pAuthInfo->ctx, &out_desc,
1245  &pAuthInfo->attr, &pAuthInfo->exp);
1246  if (sec_status == SEC_E_OK)
1247  {
1248  pAuthInfo->finished = TRUE;
1249  pAuthInfo->auth_data = out.pvBuffer;
1250  pAuthInfo->auth_data_len = out.cbBuffer;
1251  TRACE("sending last auth packet\n");
1252  }
1253  else if (sec_status == SEC_I_CONTINUE_NEEDED)
1254  {
1255  pAuthInfo->auth_data = out.pvBuffer;
1256  pAuthInfo->auth_data_len = out.cbBuffer;
1257  TRACE("sending next auth packet\n");
1258  }
1259  else
1260  {
1261  ERR("InitializeSecurityContextW returned error 0x%08x\n", sec_status);
1262  heap_free(out.pvBuffer);
1263  destroy_authinfo(pAuthInfo);
1264  *ppAuthInfo = NULL;
1265  return FALSE;
1266  }
1267  }
1268 
1269  return TRUE;
1270 }
static BOOL is_basic_auth_value(LPCWSTR pszAuthValue, LPWSTR *pszRealm)
Definition: http.c:828
unsigned int auth_data_len
Definition: http.c:160
CtxtHandle ctx
Definition: http.c:155
unsigned short * Domain
Definition: rpcdce.h:225
#define TRUE
Definition: types.h:120
unsigned short * User
Definition: rpcdce.h:223
#define SECPKG_CRED_OUTBOUND
Definition: sspi.h:277
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WideCharToMultiByte
Definition: compat.h:101
SECURITY_STATUS WINAPI AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: wrapper.c:105
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
Definition: sspi.c:699
unsigned short * Password
Definition: rpcdce.h:227
ULONG ulVersion
Definition: sspi.h:167
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
const GLint * first
Definition: glext.h:5794
#define WARN(fmt,...)
Definition: debug.h:111
static UINT HTTP_DecodeBase64(LPCWSTR base64, LPSTR bin)
Definition: http.c:1581
char * host
Definition: whois.c:55
GLuint buffer
Definition: glext.h:5915
#define ISC_REQ_DELEGATE
Definition: sspi.h:348
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define lstrlenW
Definition: compat.h:407
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static void cache_basic_authorization(LPWSTR host, LPWSTR realm, LPSTR auth_data, UINT auth_data_len)
Definition: http.c:901
#define SecInvalidateHandle(x)
Definition: sspi.h:58
static BOOL retrieve_cached_authorization(LPWSTR host, LPWSTR scheme, SEC_WINNT_AUTH_IDENTITY_W *nt_auth_identity)
Definition: http.c:941
#define CP_UTF8
Definition: nls.h:20
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG cbMaxToken
Definition: sspi.h:104
TimeStamp exp
Definition: http.c:156
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
#define debugstr_w
Definition: kernel32.h:32
LPWSTR scheme
Definition: http.c:153
static void cache_authorization(LPWSTR host, LPWSTR scheme, SEC_WINNT_AUTH_IDENTITY_W *nt_auth_identity)
Definition: http.c:978
smooth NULL
Definition: ftsmooth.c:416
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:2927
LONG SECURITY_STATUS
Definition: sspi.h:34
static void destroy_authinfo(struct HttpAuthInfo *authinfo)
Definition: http.c:864
#define TRACE(s)
Definition: solgame.cpp:4
BOOL finished
Definition: http.c:161
SECURITY_STATUS WINAPI InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:301
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SEC_WINNT_AUTH_IDENTITY_UNICODE
Definition: rpcdce.h:310
static FILE * out
Definition: regtests2xml.c:44
ULONG max_token
Definition: http.c:158
static UINT retrieve_cached_basic_authorization(const WCHAR *host, const WCHAR *realm, char **auth_data)
Definition: http.c:878
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
ULONG attr
Definition: http.c:157
#define SECBUFFER_TOKEN
Definition: sspi.h:147
#define ISC_REQ_USE_DCE_STYLE
Definition: sspi.h:357
#define SECURITY_NETWORK_DREP
Definition: sspi.h:460
void * auth_data
Definition: http.c:159
#define SEC_E_OK
Definition: winerror.h:2356
#define ISC_REQ_CONNECTION
Definition: sspi.h:359
#define ERR(fmt,...)
Definition: debug.h:109
GLuint in
Definition: glext.h:9616
unsigned int UINT
Definition: ndis.h:50
DWORD exp
Definition: msg.c:15681
#define ISC_REQ_MUTUAL_AUTH
Definition: sspi.h:349
Definition: tftpd.h:85
CredHandle cred
Definition: http.c:154
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
ULONG cBuffers
Definition: sspi.h:168
#define memset(x, y, z)
Definition: compat.h:39
void user(int argc, const char *argv[])
Definition: cmds.c:1350
SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName, PSecPkgInfoW *ppPackageInfo)
Definition: wrapper.c:750
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HTTP_HttpSendRequestW().

◆ HTTP_DomainMatches()

static BOOL HTTP_DomainMatches ( LPCWSTR  server,
substr_t  domain 
)
static

Definition at line 1731 of file http.c.

1732 {
1733  static const WCHAR localW[] = { '<','l','o','c','a','l','>',0 };
1734  const WCHAR *dot, *ptr;
1735  int len;
1736 
1737  if(domain.len == sizeof(localW)/sizeof(WCHAR)-1 && !strncmpiW(domain.str, localW, domain.len) && !strchrW(server, '.' ))
1738  return TRUE;
1739 
1740  if(domain.len && *domain.str != '*')
1741  return domain.len == strlenW(server) && !strncmpiW(server, domain.str, domain.len);
1742 
1743  if(domain.len < 2 || domain.str[1] != '.')
1744  return FALSE;
1745 
1746  /* For a hostname to match a wildcard, the last domain must match
1747  * the wildcard exactly. E.g. if the wildcard is *.a.b, and the
1748  * hostname is www.foo.a.b, it matches, but a.b does not.
1749  */
1750  dot = strchrW(server, '.');
1751  if(!dot)
1752  return FALSE;
1753 
1754  len = strlenW(dot + 1);
1755  if(len < domain.len - 2)
1756  return FALSE;
1757 
1758  /* The server's domain is longer than the wildcard, so it
1759  * could be a subdomain. Compare the last portion of the
1760  * server's domain.
1761  */
1762  ptr = dot + 1 + len - domain.len + 2;
1763  if(!strncmpiW(ptr, domain.str+2, domain.len-2))
1764  /* This is only a match if the preceding character is
1765  * a '.', i.e. that it is a matching domain. E.g.
1766  * if domain is '*.b.c' and server is 'www.ab.c' they
1767  * do not match.
1768  */
1769  return *(ptr - 1) == '.';
1770 
1771  return len == domain.len-2 && !strncmpiW(dot + 1, domain.str + 2, len);
1772 }
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * str
Definition: internet.h:200
GLenum GLsizei len
Definition: glext.h:6722
size_t len
Definition: internet.h:201

Referenced by HTTP_ShouldBypassProxy().

◆ HTTP_EncodeBase64()

static UINT HTTP_EncodeBase64 ( LPCSTR  bin,
unsigned int  len,
LPWSTR  base64 
)
static

Definition at line 1525 of file http.c.

1526 {
1527  UINT n = 0, x;
1528  static const CHAR HTTP_Base64Enc[] =
1529  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1530 
1531  while( len > 0 )
1532  {
1533  /* first 6 bits, all from bin[0] */
1534  base64[n++] = HTTP_Base64Enc[(bin[0] & 0xfc) >> 2];
1535  x = (bin[0] & 3) << 4;
1536 
1537  /* next 6 bits, 2 from bin[0] and 4 from bin[1] */
1538  if( len == 1 )
1539  {
1540  base64[n++] = HTTP_Base64Enc[x];
1541  base64[n++] = '=';
1542  base64[n++] = '=';
1543  break;
1544  }
1545  base64[n++] = HTTP_Base64Enc[ x | ( (bin[1]&0xf0) >> 4 ) ];
1546  x = ( bin[1] & 0x0f ) << 2;
1547 
1548  /* next 6 bits 4 from bin[1] and 2 from bin[2] */
1549  if( len == 2 )
1550  {
1551  base64[n++] = HTTP_Base64Enc[x];
1552  base64[n++] = '=';
1553  break;
1554  }
1555  base64[n++] = HTTP_Base64Enc[ x | ( (bin[2]&0xc0 ) >> 6 ) ];
1556 
1557  /* last 6 bits, all from bin [2] */
1558  base64[n++] = HTTP_Base64Enc[ bin[2] & 0x3f ];
1559  bin += 3;
1560  len -= 3;
1561  }
1562  base64[n] = 0;
1563  return n;
1564 }
char CHAR
Definition: xmlstorage.h:175
GLdouble n
Definition: glext.h:7729
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50
static struct _PeImage bin

Referenced by encode_auth_data().

◆ HTTP_FixURL()

static void HTTP_FixURL ( http_request_t request)
static

Definition at line 614 of file http.c.

615 {
616  static const WCHAR szSlash[] = { '/',0 };
617  static const WCHAR szHttp[] = { 'h','t','t','p',':','/','/', 0 };
618 
619  /* If we don't have a path we set it to root */
620  if (NULL == request->path)
621  request->path = heap_strdupW(szSlash);
622  else /* remove \r and \n*/
623  {
624  int nLen = strlenW(request->path);
625  while ((nLen >0 ) && ((request->path[nLen-1] == '\r')||(request->path[nLen-1] == '\n')))
626  {
627  nLen--;
628  request->path[nLen]='\0';
629  }
630  /* Replace '\' with '/' */
631  while (nLen>0) {
632  nLen--;
633  if (request->path[nLen] == '\\') request->path[nLen]='/';
634  }
635  }
636 
638  request->path, strlenW(request->path), szHttp, strlenW(szHttp) )
639  && request->path[0] != '/') /* not an absolute path ?? --> fix it !! */
640  {
641  WCHAR *fixurl = heap_alloc((strlenW(request->path) + 2)*sizeof(WCHAR));
642  *fixurl = '/';
643  strcpyW(fixurl + 1, request->path);
644  heap_free( request->path );
645  request->path = fixurl;
646  }
647 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define NORM_IGNORECASE
Definition: winnls.h:173
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2275
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CSTR_EQUAL
Definition: winnls.h:453
#define LOCALE_INVARIANT
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
Definition: tftpd.h:85
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HTTP_HttpSendRequestW().

◆ HTTP_FreeTokens()

static void HTTP_FreeTokens ( LPWSTR token_array)
static

Definition at line 607 of file http.c.

608 {
609  int i;
610  for (i = 0; token_array[i]; i++) heap_free(token_array[i]);
611  heap_free(token_array);
612 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HTTP_GetResponseHeaders(), HTTP_HttpAddRequestHeadersW(), and HTTP_InterpretHttpHeader().

◆ HTTP_GetCustomHeaderIndex() [1/2]

◆ HTTP_GetCustomHeaderIndex() [2/2]

static INT HTTP_GetCustomHeaderIndex ( http_request_t request,
LPCWSTR  lpszField,
int  requested_index,
BOOL  request_only 
)
static

Definition at line 6223 of file http.c.

6225 {
6226  DWORD index;
6227 
6228  TRACE("%s, %d, %d\n", debugstr_w(lpszField), requested_index, request_only);
6229 
6230  for (index = 0; index < request->nCustHeaders; index++)
6231  {
6232  if (strcmpiW(request->custHeaders[index].lpszField, lpszField))
6233  continue;
6234 
6235  if (request_only && !(request->custHeaders[index].wFlags & HDR_ISREQUEST))
6236  continue;
6237 
6238  if (!request_only && (request->custHeaders[index].wFlags & HDR_ISREQUEST))
6239  continue;
6240 
6241  if (requested_index == 0)
6242  break;
6243  requested_index --;
6244  }
6245 
6246  if (index >= request->nCustHeaders)
6247  index = -1;
6248 
6249  TRACE("Return: %d\n", index);
6250  return index;
6251 }
#define HDR_ISREQUEST
Definition: internet.h:315
#define debugstr_w
Definition: kernel32.h:32
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define index(s, c)
Definition: various.h:29
#define strcmpiW(s1, s2)
Definition: unicode.h:39
Definition: tftpd.h:85

◆ HTTP_GetHeader()

static LPHTTPHEADERW HTTP_GetHeader ( http_request_t req,
LPCWSTR  head 
)
static

Definition at line 372 of file http.c.

373 {
374  int HeaderIndex = 0;
375  HeaderIndex = HTTP_GetCustomHeaderIndex(req, head, 0, TRUE);
376  if (HeaderIndex == -1)
377  return NULL;
378  else
379  return &req->custHeaders[HeaderIndex];
380 }
#define TRUE
Definition: types.h:120
struct outqueuenode * head
Definition: adnsresfilter.c:66
HTTPHEADERW * custHeaders
Definition: internet.h:364
smooth NULL
Definition: ftsmooth.c:416
static INT HTTP_GetCustomHeaderIndex(http_request_t *req, LPCWSTR lpszField, INT index, BOOL Request)

Referenced by get_host_header(), and HTTP_HttpSendRequestW().

◆ HTTP_GetResponseHeaders()

static DWORD HTTP_GetResponseHeaders ( http_request_t req,
INT len 
)
static

Definition at line 5903 of file http.c.

5904 {
5905  INT cbreaks = 0;
5907  DWORD buflen = MAX_REPLY_LEN;
5908  INT rc = 0;
5909  char bufferA[MAX_REPLY_LEN];
5910  LPWSTR status_code = NULL, status_text = NULL;
5912  BOOL codeHundred = FALSE;
5913 
5914  TRACE("-->\n");
5915 
5916  if(!is_valid_netconn(request->netconn))
5917  goto lend;
5918 
5919  /* clear old response headers (eg. from a redirect response) */
5921 
5922  NETCON_set_timeout( request->netconn, FALSE, request->receive_timeout );
5923  do {
5924  /*
5925  * We should first receive 'HTTP/1.x nnn OK' where nnn is the status code.
5926  */
5927  buflen = MAX_REPLY_LEN;
5928  if ((res = read_line(request, bufferA, &buflen)))
5929  goto lend;
5930 
5931  if (!buflen) goto lend;
5932 
5933  rc += buflen;
5934  MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
5935  /* check is this a status code line? */
5936  if (!strncmpW(buffer, g_szHttp1_0, 4))
5937  {
5938  /* split the version from the status code */
5939  status_code = strchrW( buffer, ' ' );
5940  if( !status_code )
5941  goto lend;
5942  *status_code++=0;
5943 
5944  /* split the status code from the status text */
5945  status_text = strchrW( status_code, ' ' );
5946  if( status_text )
5947  *status_text++=0;
5948 
5949  request->status_code = atoiW(status_code);
5950 
5951  TRACE("version [%s] status code [%s] status text [%s]\n",
5952  debugstr_w(buffer), debugstr_w(status_code), debugstr_w(status_text) );
5953 
5954  codeHundred = request->status_code == HTTP_STATUS_CONTINUE;
5955  }
5956  else if (!codeHundred)
5957  {
5958  WARN("No status line at head of response (%s)\n", debugstr_w(buffer));
5959 
5960  heap_free(request->version);
5961  heap_free(request->statusText);
5962 
5963  request->status_code = HTTP_STATUS_OK;
5964  request->version = heap_strdupW(g_szHttp1_0);
5965  request->statusText = heap_strdupW(szOK);
5966 
5967  goto lend;
5968  }
5969  } while (codeHundred);
5970 
5971  /* Add status code */
5974 
5975  heap_free(request->version);
5976  heap_free(request->statusText);
5977 
5978  request->version = heap_strdupW(buffer);
5979  request->statusText = heap_strdupW(status_text ? status_text : emptyW);
5980 
5981  /* Restore the spaces */
5982  *(status_code-1) = ' ';
5983  if (status_text)
5984  *(status_text-1) = ' ';
5985 
5986  /* Parse each response line */
5987  do
5988  {
5989  buflen = MAX_REPLY_LEN;
5990  if (!read_line(request, bufferA, &buflen) && buflen)
5991  {
5992  LPWSTR * pFieldAndValue;
5993 
5994  TRACE("got line %s, now interpreting\n", debugstr_a(bufferA));
5995 
5996  if (!bufferA[0]) break;
5997  MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
5998 
5999  pFieldAndValue = HTTP_InterpretHttpHeader(buffer);
6000  if (pFieldAndValue)
6001  {
6002  HTTP_ProcessHeader(request, pFieldAndValue[0], pFieldAndValue[1],
6004  HTTP_FreeTokens(pFieldAndValue);
6005  }
6006  }
6007  else
6008  {
6009  cbreaks++;
6010  if (cbreaks >= 2)
6011  break;
6012  }
6013  }while(1);
6014 
6015  res = ERROR_SUCCESS;
6016 
6017 lend:
6018 
6019  *len = rc;
6020  TRACE("<--\n");
6021  return res;
6022 }
static const WCHAR g_szHttp1_0[]
Definition: http.c:67
#define HTTP_ADDHDR_FLAG_REPLACE
Definition: http.c:143
#define ERROR_SUCCESS
Definition: deptool.c:10
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define CP_ACP
Definition: compat.h:99
#define WARN(fmt,...)
Definition: debug.h:111
static void HTTP_clear_response_headers(http_request_t *request)
Definition: http.c:5872
GLuint buffer
Definition: glext.h:5915
int32_t INT
Definition: typedefs.h:56
#define ERROR_HTTP_INVALID_SERVER_RESPONSE
Definition: wininet.h:2059
WINE_UNICODE_INLINE int strncmpW(const WCHAR *str1, const WCHAR *str2, int n)
Definition: unicode.h:235
#define MAX_REPLY_LEN
Definition: request.c:2386
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR emptyW[]
Definition: http.c:132
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
#define debugstr_w
Definition: kernel32.h:32
#define HTTP_ADDREQ_FLAG_ADD
Definition: wininet.h:1707
smooth NULL
Definition: ftsmooth.c:416
static DWORD HTTP_ProcessHeader(http_request_t *req, LPCWSTR field, LPCWSTR value, DWORD dwModifier)
Definition: http.c:6088
static DWORD read_line(http_request_t *req, LPSTR buffer, DWORD *len)
Definition: http.c:2522
DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, DWORD value) DECLSPEC_HIDDEN
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
static const WCHAR szStatus[]
Definition: http.c:73
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
static LPWSTR * HTTP_InterpretHttpHeader(LPCWSTR buffer)
Definition: http.c:6034
GLenum GLsizei len
Definition: glext.h:6722
BOOL is_valid_netconn(netconn_t *) DECLSPEC_HIDDEN
#define MultiByteToWideChar
Definition: compat.h:100
Definition: tftpd.h:85
static void HTTP_FreeTokens(LPWSTR *token_array)
Definition: http.c:607
#define HTTP_STATUS_CONTINUE
Definition: winhttp.h:238
#define HTTP_ADDHDR_FLAG_ADD
Definition: http.c:138
GLuint res
Definition: glext.h:9613
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static const WCHAR szOK[]
Definition: http.c:69
WINE_UNICODE_INLINE int atoiW(const WCHAR *str)
Definition: unicode.h:315
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by HTTP_HttpEndRequestW(), and HTTP_HttpSendRequestW().

◆ HTTP_HandleRedirect()

static DWORD HTTP_HandleRedirect ( http_request_t request,
WCHAR url 
)
static

Definition at line 4080 of file http.c.

4081 {
4082  URL_COMPONENTSW urlComponents = { sizeof(urlComponents) };
4083  http_session_t *session = request->session;
4084  size_t url_len = strlenW(url);
4085 
4086  if(url[0] == '/')
4087  {
4088  /* if it's an absolute path, keep the same session info */
4089  urlComponents.lpszUrlPath = url;
4090  urlComponents.dwUrlPathLength = url_len;
4091  }
4092  else
4093  {
4094  urlComponents.dwHostNameLength = 1;
4095  urlComponents.dwUserNameLength = 1;
4096  urlComponents.dwUrlPathLength = 1;
4097  if(!InternetCrackUrlW(url, url_len, 0, &urlComponents))
4098  return INTERNET_GetLastError();
4099 
4100  if(!urlComponents.dwHostNameLength)
4102  }
4103 
4105  url, (url_len + 1) * sizeof(WCHAR));
4106 
4107  if(urlComponents.dwHostNameLength) {
4108  BOOL custom_port = FALSE;
4109  substr_t host;
4110 
4111  if(urlComponents.nScheme == INTERNET_SCHEME_HTTP) {
4112  if(request->hdr.dwFlags & INTERNET_FLAG_SECURE) {
4113  TRACE("redirect from secure page to non-secure page\n");
4114  /* FIXME: warn about from secure redirect to non-secure page */
4115  request->hdr.dwFlags &= ~INTERNET_FLAG_SECURE;
4116  }
4117 
4118  custom_port = urlComponents.nPort != INTERNET_DEFAULT_HTTP_PORT;
4119  }else if(urlComponents.nScheme == INTERNET_SCHEME_HTTPS) {
4120  if(!(request->hdr.dwFlags & INTERNET_FLAG_SECURE)) {
4121  TRACE("redirect from non-secure page to secure page\n");
4122  /* FIXME: notify about redirect to secure page */
4123  request->hdr.dwFlags |= INTERNET_FLAG_SECURE;
4124  }
4125 
4126  custom_port = urlComponents.nPort != INTERNET_DEFAULT_HTTPS_PORT;
4127  }
4128 
4129  heap_free(session->hostName);
4130 
4131  session->hostName = heap_strndupW(urlComponents.lpszHostName, urlComponents.dwHostNameLength);
4132  session->hostPort = urlComponents.nPort;
4133 
4134  heap_free(session->userName);
4135  session->userName = NULL;
4136  if (urlComponents.dwUserNameLength)
4137  session->userName = heap_strndupW(urlComponents.lpszUserName, urlComponents.dwUserNameLength);
4138 
4140 
4141  host = substr(urlComponents.lpszHostName, urlComponents.dwHostNameLength);
4142 
4143  if(