ReactOS  0.4.14-dev-583-g2a1ba2c
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 <errno.h>
#include <limits.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_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_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 FE(x)   { x, #x }
 
#define COALESCEFLAGS   (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 (http_request_t *req, 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)
 
void free_authorization_cache (void)
 
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

◆ 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 136 of file http.c.

◆ HTTP_ADDHDR_FLAG_ADD

#define HTTP_ADDHDR_FLAG_ADD   0x20000000

Definition at line 139 of file http.c.

◆ HTTP_ADDHDR_FLAG_ADD_IF_NEW

#define HTTP_ADDHDR_FLAG_ADD_IF_NEW   0x10000000

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 135 of file http.c.

◆ HTTP_USERAGENT

#define HTTP_USERAGENT   szUser_Agent

Definition at line 137 of file http.c.

◆ NO_SHLWAPI_GDI

#define NO_SHLWAPI_GDI

Definition at line 55 of file http.c.

◆ NO_SHLWAPI_REG

#define NO_SHLWAPI_REG

Definition at line 54 of file http.c.

◆ NO_SHLWAPI_STREAM

#define NO_SHLWAPI_STREAM

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 3167 of file http.c.

3168 {
3169  read_file_task_t *task;
3170 
3171  task = alloc_async_task(&req->hdr, async_read_file_proc, sizeof(*task));
3172  if(!task)
3173  return ERROR_OUTOFMEMORY;
3174 
3175  task->buf = buf;
3176  task->size = size;
3177  task->read_pos = read_pos;
3178  task->ret_read = ret_read;
3179 
3180  INTERNET_AsyncCall(&task->hdr);
3181  return ERROR_IO_PENDING;
3182 }
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:3120
object_header_t hdr
Definition: internet.h:346
DWORD * ret_read
Definition: http.c:3124
DWORD read_pos
Definition: http.c:3123
GLsizeiptr size
Definition: glext.h:5919
void * buf
Definition: http.c:3121
void * alloc_async_task(object_header_t *hdr, async_task_proc_t proc, size_t size)
Definition: internet.c:3777
DWORD INTERNET_AsyncCall(task_header_t *task)
Definition: internet.c:3798
DWORD size
Definition: http.c:3122
static void async_read_file_proc(task_header_t *hdr)
Definition: http.c:3127
#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 3127 of file http.c.

3128 {
3130  http_request_t *req = (http_request_t*)task->hdr.hdr;
3131  DWORD res = ERROR_SUCCESS, read = task->read_pos, complete_arg = 0;
3132 
3133  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);
3134 
3135  if(task->buf) {
3136  DWORD read_bytes;
3137  while (read < task->size) {
3138  res = HTTPREQ_Read(req, (char*)task->buf + read, task->size - read, &read_bytes, TRUE);
3139  if (res != ERROR_SUCCESS || !read_bytes)
3140  break;
3141  read += read_bytes;
3142  }
3143  }else {
3145  res = refill_read_buffer(req, TRUE, &read);
3147 
3148  if(task->ret_read)
3149  complete_arg = read; /* QueryDataAvailable reports read bytes in request complete notification */
3150  if(res != ERROR_SUCCESS || !read)
3152  }
3153 
3154  TRACE("res %u read %u\n", res, read);
3155 
3156  if(task->ret_read)
3157  *task->ret_read = read;
3158 
3159  /* FIXME: We should report bytes transferred before decoding content. */
3161 
3162  if(res != ERROR_SUCCESS)
3163  complete_arg = res;
3164  send_request_complete(req, res == ERROR_SUCCESS, complete_arg);
3165 }
#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:168
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:3063
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:3120
object_header_t hdr
Definition: internet.h:346
DWORD * ret_read
Definition: http.c:3124
DWORD read_pos
Definition: http.c:3123
static void send_request_complete(http_request_t *req, DWORD_PTR result, DWORD error)
Definition: http.c:3024
#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:2000
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD drain_content(http_request_t *, BOOL)
Definition: http.c:3101
void * buf
Definition: http.c:3121
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:2662
CRITICAL_SECTION read_section
Definition: internet.h:374
GLuint res
Definition: glext.h:9613
DWORD size
Definition: http.c:3122
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 5405 of file http.c.

5406 {
5408  http_request_t *req = (http_request_t*)task->hdr.hdr;
5409 
5410  TRACE("%p\n", req);
5411 
5412  HTTP_HttpEndRequestW(req, task->flags, task->context);
5413 }
char hdr[14]
Definition: iptest.cpp:33
task_header_t hdr
Definition: http.c:5400
#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:5305

Referenced by HttpEndRequestW().

◆ AsyncHttpSendRequestProc()

static void AsyncHttpSendRequestProc ( task_header_t hdr)
static

Definition at line 5291 of file http.c.

5292 {
5295 
5296  TRACE("%p\n", request);
5297 
5299  task->optional_len, task->content_len, task->end_request);
5300 
5301  heap_free(task->headers);
5302 }
char hdr[14]
Definition: iptest.cpp:33
DWORD headers_len
Definition: http.c:5279
void * optional
Definition: http.c:5280
DWORD optional_len
Definition: http.c:5281
WCHAR * headers
Definition: http.c:5278
#define TRACE(s)
Definition: solgame.cpp:4
object_header_t * hdr
Definition: internet.h:391
task_header_t hdr
Definition: http.c:5277
Definition: tftpd.h:85
DWORD content_len
Definition: http.c:5282
static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength, DWORD dwContentLength, BOOL bEndRequest)
Definition: http.c:4943
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 4910 of file http.c.

4911 {
4912  int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
4913  char *ret;
4914 
4915  if (!(ret = heap_alloc( len + data_len ))) return NULL;
4916  WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
4917  if (data_len) memcpy( ret + len - 1, data, data_len );
4918  *out_len = len + data_len - 1;
4919  ret[*out_len] = 0;
4920  return ret;
4921 }
#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 1757 of file http.c.

1758 {
1759  DWORD size, len;
1760  WCHAR *url;
1761 
1763  size = len + strlenW(req->path) + 1;
1764  if(*req->path != '/')
1765  size++;
1766  url = heap_alloc(size * sizeof(WCHAR));
1767  if(!url)
1768  return NULL;
1769 
1770  memcpy(url, req->server->scheme_host_port, len*sizeof(WCHAR));
1771  if(*req->path != '/')
1772  url[len++] = '/';
1773 
1774  strcpyW(url+len, req->path);
1775 
1776  TRACE("url=%s\n", debugstr_w(url));
1777  return url;
1778 }
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 646 of file http.c.

648 {
649  static const WCHAR szSpace[] = {' ',0};
650  static const WCHAR szColon[] = {':',' ',0};
651  static const WCHAR szCr[] = {'\r',0};
652  static const WCHAR szLf[] = {'\n',0};
653  LPWSTR requestString;
654  DWORD len, n;
655  LPCWSTR *req;
656  UINT i;
657 
658  EnterCriticalSection( &request->headers_section );
659 
660  /* allocate space for an array of all the string pointers to be added */
661  len = request->nCustHeaders * 5 + 10;
662  if (!(req = heap_alloc( len * sizeof(const WCHAR *) )))
663  {
664  LeaveCriticalSection( &request->headers_section );
665  return NULL;
666  }
667 
668  /* add the verb, path and HTTP version string */
669  n = 0;
670  req[n++] = verb;
671  req[n++] = szSpace;
672  req[n++] = path;
673  req[n++] = szSpace;
674  req[n++] = version;
675  if (use_cr)
676  req[n++] = szCr;
677  req[n++] = szLf;
678 
679  /* Append custom request headers */
680  for (i = 0; i < request->nCustHeaders; i++)
681  {
682  if (request->custHeaders[i].wFlags & HDR_ISREQUEST)
683  {
684  req[n++] = request->custHeaders[i].lpszField;
685  req[n++] = szColon;
686  req[n++] = request->custHeaders[i].lpszValue;
687  if (use_cr)
688  req[n++] = szCr;
689  req[n++] = szLf;
690 
691  TRACE("Adding custom header %s (%s)\n",
692  debugstr_w(request->custHeaders[i].lpszField),
693  debugstr_w(request->custHeaders[i].lpszValue));
694  }
695  }
696  if (use_cr)
697  req[n++] = szCr;
698  req[n++] = szLf;
699  req[n] = NULL;
700 
701  requestString = HTTP_build_req( req, 4 );
702  heap_free( req );
703  LeaveCriticalSection( &request->headers_section );
704  return requestString;
705 }
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:4270
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:66
#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 707 of file http.c.

708 {
709  static const WCHAR colonW[] = { ':',' ',0 };
710  static const WCHAR crW[] = { '\r',0 };
711  static const WCHAR lfW[] = { '\n',0 };
712  static const WCHAR status_fmt[] = { ' ','%','u',' ',0 };
713  const WCHAR **req;
714  WCHAR *ret, buf[14];
715  DWORD i, n = 0;
716 
717  EnterCriticalSection( &request->headers_section );
718 
719  if (!(req = heap_alloc( (request->nCustHeaders * 5 + 8) * sizeof(WCHAR *) )))
720  {
721  LeaveCriticalSection( &request->headers_section );
722  return NULL;
723  }
724 
725  if (request->status_code)
726  {
727  req[n++] = request->version;
728  sprintfW(buf, status_fmt, request->status_code);
729  req[n++] = buf;
730  req[n++] = request->statusText;
731  if (use_cr)
732  req[n++] = crW;
733  req[n++] = lfW;
734  }
735 
736  for(i = 0; i < request->nCustHeaders; i++)
737  {
738  if(!(request->custHeaders[i].wFlags & HDR_ISREQUEST)
739  && strcmpW(request->custHeaders[i].lpszField, szStatus))
740  {
741  req[n++] = request->custHeaders[i].lpszField;
742  req[n++] = colonW;
743  req[n++] = request->custHeaders[i].lpszValue;
744  if(use_cr)
745  req[n++] = crW;
746  req[n++] = lfW;
747 
748  TRACE("Adding custom header %s (%s)\n",
749  debugstr_w(request->custHeaders[i].lpszField),
750  debugstr_w(request->custHeaders[i].lpszValue));
751  }
752  }
753  if(use_cr)
754  req[n++] = crW;
755  req[n++] = lfW;
756  req[n] = NULL;
757 
758  ret = HTTP_build_req(req, 0);
759  heap_free(req);
760  LeaveCriticalSection( &request->headers_section );
761  return ret;
762 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
WCHAR * version
GLdouble n
Definition: glext.h:7729
static LPWSTR HTTP_build_req(LPCWSTR *list, int len)
Definition: http.c:4270
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:74
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 989 of file http.c.

991 {
992  authorizationData *ad;
993  BOOL found = FALSE;
994 
995  TRACE("Caching authorization for %s:%s\n", debugstr_w(host), debugstr_w(scheme));
996 
999  if(!strcmpiW(host, ad->host) && !strcmpiW(scheme, ad->scheme)) {
1000  found = TRUE;
1001  break;
1002  }
1003 
1004  if(found) {
1005  heap_free(ad->user);
1006  heap_free(ad->password);
1007  heap_free(ad->domain);
1008  } else {
1009  ad = heap_alloc(sizeof(authorizationData));
1010  if(!ad) {
1012  return;
1013  }
1014 
1015  ad->host = heap_strdupW(host);
1016  ad->scheme = heap_strdupW(scheme);
1018  }
1019 
1020  ad->user = heap_strndupW(nt_auth_identity->User, nt_auth_identity->UserLength);
1021  ad->password = heap_strndupW(nt_auth_identity->Password, nt_auth_identity->PasswordLength);
1022  ad->domain = heap_strndupW(nt_auth_identity->Domain, nt_auth_identity->DomainLength);
1023  ad->user_len = nt_auth_identity->UserLength;
1024  ad->password_len = nt_auth_identity->PasswordLength;
1025  ad->domain_len = nt_auth_identity->DomainLength;
1026 
1027  if(!ad->host || !ad->scheme || !ad->user || !ad->password
1028  || (nt_auth_identity->Domain && !ad->domain)) {
1029  heap_free(ad->host);
1030  heap_free(ad->scheme);
1031  heap_free(ad->user);
1032  heap_free(ad->password);
1033  heap_free(ad->domain);
1034  list_remove(&ad->entry);
1035  heap_free(ad);
1036  }
1037 
1039 }
struct list entry
Definition: http.c:174
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:182
static LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
UINT password_len
Definition: http.c:183
LPWSTR domain
Definition: http.c:178
unsigned short * Password
Definition: rpcdce.h:227
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:179
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
uint32_t entry
Definition: isohybrid.c:63
#define strcmpiW(s1, s2)
Definition: unicode.h:39
LPWSTR scheme
Definition: http.c:177
LPWSTR host
Definition: http.c:176
LPWSTR user
Definition: http.c:180
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static struct list authorizationCache
Definition: http.c:187
static CRITICAL_SECTION authcache_cs
Definition: http.c:189

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 912 of file http.c.

913 {
914  struct list *cursor;
916 
917  TRACE("caching authorization for %s:%s = %s\n",debugstr_w(host),debugstr_w(realm),debugstr_an(auth_data,auth_data_len));
918 
921  {
923  if (!strcmpiW(host,check->host) && !strcmpW(realm,check->realm))
924  {
925  ad = check;
926  break;
927  }
928  }
929 
930  if (ad)
931  {
932  TRACE("Found match in cache, replacing\n");
934  ad->authorization = heap_alloc(auth_data_len);
935  memcpy(ad->authorization, auth_data, auth_data_len);
936  ad->authorizationLen = auth_data_len;
937  }
938  else
939  {
940  ad = heap_alloc(sizeof(basicAuthorizationData));
941  ad->host = heap_strdupW(host);
942  ad->realm = heap_strdupW(realm);
943  ad->authorization = heap_alloc(auth_data_len);
944  memcpy(ad->authorization, auth_data, auth_data_len);
945  ad->authorizationLen = auth_data_len;
947  TRACE("authorization cached\n");
948  }
950 }
static struct list basicAuthorizationCache
Definition: http.c:186
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
uint32_t entry
Definition: isohybrid.c:63
#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:164
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:189

Referenced by HTTP_DoAuthorization().

◆ chunked_destroy()

static void chunked_destroy ( data_stream_t stream)
static

Definition at line 2934 of file http.c.

2935 {
2936  chunked_stream_t *chunked_stream = (chunked_stream_t*)stream;
2937  heap_free(chunked_stream);
2938 }
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 2916 of file http.c.

2917 {
2918  chunked_stream_t *chunked_stream = (chunked_stream_t*)stream;
2919  BYTE buf[1024];
2920  DWORD size, res;
2921 
2922  while(chunked_stream->state != CHUNKED_STREAM_STATE_END_OF_STREAM
2923  && chunked_stream->state != CHUNKED_STREAM_STATE_ERROR) {
2924  res = chunked_read(stream, req, buf, sizeof(buf), &size, allow_blocking);
2925  if(res != ERROR_SUCCESS)
2926  return res;
2927  }
2928 
2929  if(chunked_stream->state != CHUNKED_STREAM_STATE_END_OF_STREAM)
2930  return ERROR_NO_DATA;
2931  return ERROR_SUCCESS;
2932 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizeiptr size
Definition: glext.h:5919
enum chunked_stream_t::@581 state
#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:2773
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 2760 of file http.c.

2761 {
2762  chunked_stream_t *chunked_stream = (chunked_stream_t*)stream;
2763  switch(chunked_stream->state) {
2764  case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END:
2765  case CHUNKED_STREAM_STATE_END_OF_STREAM:
2766  case CHUNKED_STREAM_STATE_ERROR:
2767  return TRUE;
2768  default:
2769  return FALSE;
2770  }
2771 }
#define TRUE
Definition: types.h:120
enum chunked_stream_t::@581 state
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 2773 of file http.c.

2775 {
2776  chunked_stream_t *chunked_stream = (chunked_stream_t*)stream;
2777  DWORD ret_read = 0, res = ERROR_SUCCESS;
2778  BOOL continue_read = TRUE;
2779  int read_bytes;
2780  char ch;
2781 
2782  do {
2783  TRACE("state %d\n", chunked_stream->state);
2784 
2785  /* Ensure that we have data in the buffer for states that need it. */
2786  if(!chunked_stream->buf_size) {
2787  BOOL blocking_read = allow_blocking;
2788 
2789  switch(chunked_stream->state) {
2790  case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END:
2791  case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE:
2792  /* never allow blocking after 0 chunk size */
2793  if(!chunked_stream->chunk_size)
2794  blocking_read = FALSE;
2795  /* fall through */
2796  case CHUNKED_STREAM_STATE_READING_CHUNK_SIZE:
2797  case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA:
2798  chunked_stream->buf_pos = 0;
2799  res = NETCON_recv(req->netconn, chunked_stream->buf, sizeof(chunked_stream->buf), blocking_read, &read_bytes);
2800  if(res == ERROR_SUCCESS && read_bytes) {
2801  chunked_stream->buf_size += read_bytes;
2802  }else if(res == WSAEWOULDBLOCK) {
2803  if(ret_read || allow_blocking)
2804  res = ERROR_SUCCESS;
2805  continue_read = FALSE;
2806  continue;
2807  }else {
2808  chunked_stream->state = CHUNKED_STREAM_STATE_ERROR;
2809  }
2810  break;
2811  default:
2812  break;
2813  }
2814  }
2815 
2816  switch(chunked_stream->state) {
2817  case CHUNKED_STREAM_STATE_READING_CHUNK_SIZE:
2818  ch = next_chunked_data_char(chunked_stream);
2819 
2820  if(ch >= '0' && ch <= '9') {
2821  chunked_stream->chunk_size = chunked_stream->chunk_size * 16 + ch - '0';
2822  }else if(ch >= 'a' && ch <= 'f') {
2823  chunked_stream->chunk_size = chunked_stream->chunk_size * 16 + ch - 'a' + 10;
2824  }else if (ch >= 'A' && ch <= 'F') {
2825  chunked_stream->chunk_size = chunked_stream->chunk_size * 16 + ch - 'A' + 10;
2826  }else if (ch == ';' || ch == '\r' || ch == '\n') {
2827  TRACE("reading %u byte chunk\n", chunked_stream->chunk_size);
2828  chunked_stream->buf_size++;
2829  chunked_stream->buf_pos--;
2830  if(req->contentLength == ~0) req->contentLength = chunked_stream->chunk_size;
2831  else req->contentLength += chunked_stream->chunk_size;
2832  chunked_stream->state = CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE;
2833  }
2834  break;
2835 
2836  case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE:
2837  ch = next_chunked_data_char(chunked_stream);
2838  if(ch == '\n')
2839  chunked_stream->state = chunked_stream->chunk_size
2840  ? CHUNKED_STREAM_STATE_READING_CHUNK
2841  : CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END;
2842  else if(ch != '\r')
2843  WARN("unexpected char '%c'\n", ch);
2844  break;
2845 
2846  case CHUNKED_STREAM_STATE_READING_CHUNK:
2847  assert(chunked_stream->chunk_size);
2848  if(!size) {
2849  continue_read = FALSE;
2850  break;
2851  }
2852  read_bytes = min(size, chunked_stream->chunk_size);
2853 
2854  if(chunked_stream->buf_size) {
2855  if(read_bytes > chunked_stream->buf_size)
2856  read_bytes = chunked_stream->buf_size;
2857 
2858  memcpy(buf+ret_read, chunked_stream->buf+chunked_stream->buf_pos, read_bytes);
2859  chunked_stream->buf_pos += read_bytes;
2860  chunked_stream->buf_size -= read_bytes;
2861  }else {
2862  res = NETCON_recv(req->netconn, (char*)buf+ret_read, read_bytes,
2863  allow_blocking, (int*)&read_bytes);
2864  if(res != ERROR_SUCCESS) {
2865  continue_read = FALSE;
2866  break;
2867  }
2868 
2869  if(!read_bytes) {
2870  chunked_stream->state = CHUNKED_STREAM_STATE_ERROR;
2871  continue;
2872  }
2873  }
2874 
2875  chunked_stream->chunk_size -= read_bytes;
2876  size -= read_bytes;
2877  ret_read += read_bytes;
2878  if(!chunked_stream->chunk_size)
2879  chunked_stream->state = CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA;
2880  allow_blocking = FALSE;
2881  break;
2882 
2883  case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA:
2884  ch = next_chunked_data_char(chunked_stream);
2885  if(ch == '\n')
2886  chunked_stream->state = CHUNKED_STREAM_STATE_READING_CHUNK_SIZE;
2887  else if(ch != '\r')
2888  WARN("unexpected char '%c'\n", ch);
2889  break;
2890 
2891  case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END:
2892  ch = next_chunked_data_char(chunked_stream);
2893  if(ch == '\n')
2894  chunked_stream->state = CHUNKED_STREAM_STATE_END_OF_STREAM;
2895  else if(ch != '\r')
2896  WARN("unexpected char '%c'\n", ch);
2897  break;
2898 
2899  case CHUNKED_STREAM_STATE_END_OF_STREAM:
2900  case CHUNKED_STREAM_STATE_ERROR:
2901  continue_read = FALSE;
2902  break;
2903  }
2904  } while(continue_read);
2905 
2906  if(ret_read)
2907  res = ERROR_SUCCESS;
2908  if(res != ERROR_SUCCESS)
2909  return res;
2910 
2911  TRACE("read %d bytes\n", ret_read);
2912  *read = ret_read;
2913  return ERROR_SUCCESS;
2914 }
DWORD chunk_size
Definition: http.c:404
#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:403
BYTE buf[READ_BUFFER_SIZE]
Definition: http.c:401
#define WARN(fmt,...)
Definition: debug.h:111
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
ULONGLONG contentLength
Definition: internet.h:375
#define assert(x)
Definition: debug.h:53
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:168
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
enum chunked_stream_t::@581 state
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:2752
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
DWORD buf_size
Definition: http.c:402
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 310 of file http.c.

311 {
312  netconn_t *netconn, *netconn_safe;
313  server_t *server, *server_safe;
314  BOOL remaining = FALSE;
315  DWORD64 now;
316 
317 #ifdef __REACTOS__
318  now = GetTickCount();
319 #else
320  now = GetTickCount64();
321 #endif
322 
324  LIST_FOR_EACH_ENTRY_SAFE(netconn, netconn_safe, &server->conn_pool, netconn_t, pool_entry) {
325  if(collect_type > COLLECT_TIMEOUT || netconn->keep_until < now) {
326  TRACE("freeing %p\n", netconn);
327  list_remove(&netconn->pool_entry);
329  }else {
330  remaining = TRUE;
331  }
332  }
333 
334  if(collect_type == COLLECT_CLEANUP) {
335  list_remove(&server->entry);
336  list_init(&server->entry);
338  }
339  }
340 
341  return remaining;
342 }
ULONGLONG keep_until
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
void server_release(server_t *server)
Definition: http.c:226
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
unsigned int BOOL
Definition: ntddk_ex.h:94
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
uint32_t entry
Definition: isohybrid.c:63
#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
static struct list connection_pool
Definition: http.c:218

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

◆ collect_connections_proc()

static DWORD WINAPI collect_connections_proc ( void arg)
static

Definition at line 344 of file http.c.

345 {
346  BOOL remaining_conns;
347 
348  do {
349  /* FIXME: Use more sophisticated method */
350  Sleep(5000);
351 
353 
354  remaining_conns = collect_connections(COLLECT_TIMEOUT);
355  if(!remaining_conns)
357 
359  }while(remaining_conns);
360 
362 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode)
Definition: loader.c:516
HMODULE WININET_hModule
Definition: internet.c:76
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL collector_running
Definition: http.c:219
static CRITICAL_SECTION connection_pool_cs
Definition: http.c:209
BOOL collect_connections(collect_type_t collect_type)
Definition: http.c:310
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 2428 of file http.c.

2429 {
2430  WCHAR *header;
2431  DWORD header_len;
2432  BOOL res;
2433 
2434  TRACE("%p\n", req);
2435 
2436  CloseHandle(req->hCacheFile);
2437  req->hCacheFile = NULL;
2438 
2440  header_len = (header ? strlenW(header) : 0);
2443  header, header_len, NULL, 0);
2444  if(res)
2445  req->req_file->is_committed = TRUE;
2446  else
2447  WARN("CommitUrlCacheEntry failed: %u\n", GetLastError());
2448  heap_free(header);
2449 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
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:2087
#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:3097
__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:707
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:101
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 1918 of file http.c.

1919 {
1920  static const WCHAR http[] = { 'h','t','t','p',':','/','/',0 };
1921  static const WCHAR https[] = { 'h','t','t','p','s',':','/','/',0 };
1922  const WCHAR *host, *scheme;
1923  WCHAR *buf, *ptr;
1924  size_t len;
1925 
1926  host = req->server->canon_host_port;
1927 
1928  if (req->server->is_https)
1929  scheme = https;
1930  else
1931  scheme = http;
1932 
1933  len = strlenW(scheme) + strlenW(host) + (req->path[0] != '/' ? 1 : 0) + strlenW(req->path);
1934  ptr = buf = heap_alloc((len+1) * sizeof(WCHAR));
1935  if(buf) {
1936  strcpyW(ptr, scheme);
1937  ptr += strlenW(ptr);
1938 
1939  strcpyW(ptr, host);
1940  ptr += strlenW(ptr);
1941 
1942  if(req->path[0] != '/')
1943  *ptr++ = '/';
1944 
1945  strcpyW(ptr, req->path);
1946  ptr += strlenW(ptr);
1947  *ptr = 0;
1948  }
1949 
1950  return buf;
1951 }
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 1458 of file http.c.

1459 {
1460  unsigned int count;
1461  const char **types = accept_types;
1462  WCHAR **typesW;
1463  BOOL invalid_pointer = FALSE;
1464 
1465  if (!types) return NULL;
1466  count = 0;
1467  while (*types)
1468  {
1469  __TRY
1470  {
1471  /* find out how many there are */
1472  if (*types && **types)
1473  {
1474  TRACE("accept type: %s\n", debugstr_a(*types));
1475  count++;
1476  }
1477  }
1479  {
1480  WARN("invalid accept type pointer\n");
1481  invalid_pointer = TRUE;
1482  }
1483  __ENDTRY;
1484  types++;
1485  }
1486  if (invalid_pointer) return NULL;
1487  if (!(typesW = heap_alloc( sizeof(WCHAR *) * (count + 1) ))) return NULL;
1488  count = 0;
1489  types = accept_types;
1490  while (*types)
1491  {
1492  if (*types && **types) typesW[count++] = heap_strdupAtoW( *types );
1493  types++;
1494  }
1495  typesW[count] = NULL;
1496  return typesW;
1497 }
#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 2451 of file http.c.

2452 {
2453  static const WCHAR no_cacheW[] = {'n','o','-','c','a','c','h','e',0};
2454  static const WCHAR no_storeW[] = {'n','o','-','s','t','o','r','e',0};
2455 
2457  WCHAR *url;
2458  BOOL b = TRUE;
2459 
2460  /* FIXME: We should free previous cache file earlier */
2461  if(req->req_file) {
2462  req_file_release(req->req_file);
2463  req->req_file = NULL;
2464  }
2465  if(req->hCacheFile) {
2466  CloseHandle(req->hCacheFile);
2467  req->hCacheFile = NULL;
2468  }
2469 
2471  b = FALSE;
2472 
2473  if(b) {
2474  int header_idx;
2475 
2477 
2478  header_idx = HTTP_GetCustomHeaderIndex(req, szCache_Control, 0, FALSE);
2479  if(header_idx != -1) {
2480  WCHAR *ptr;
2481 
2482  for(ptr=req->custHeaders[header_idx].lpszValue; *ptr; ) {
2483  WCHAR *end;
2484 
2485  while(*ptr==' ' || *ptr=='\t')
2486  ptr++;
2487 
2488  end = strchrW(ptr, ',');
2489  if(!end)
2490  end = ptr + strlenW(ptr);
2491 
2492  if(!strncmpiW(ptr, no_cacheW, ARRAY_SIZE(no_cacheW)-1)
2493  || !strncmpiW(ptr, no_storeW, ARRAY_SIZE(no_storeW)-1)) {
2494  b = FALSE;
2495  break;
2496  }
2497 
2498  ptr = end;
2499  if(*ptr == ',')
2500  ptr++;
2501  }
2502  }
2503 
2505  }
2506 
2507  if(!b) {
2508  if(!(req->hdr.dwFlags & INTERNET_FLAG_NEED_FILE))
2509  return;
2510 
2511  FIXME("INTERNET_FLAG_NEED_FILE is not supported correctly\n");
2512  }
2513 
2514  url = compose_request_url(req);
2515  if(!url) {
2516  WARN("Could not get URL\n");
2517  return;
2518  }
2519 
2520  b = CreateUrlCacheEntryW(url, req->contentLength == ~0 ? 0 : req->contentLength, NULL, file_name, 0);
2521  if(!b) {
2522  WARN("Could not create cache entry: %08x\n", GetLastError());
2523  return;
2524  }
2525 
2527  req->req_file->url = url;
2528 
2531  if(req->hCacheFile == INVALID_HANDLE_VALUE) {
2532  WARN("Could not create file: %u\n", GetLastError());
2533  req->hCacheFile = NULL;
2534  return;
2535  }
2536 
2537  if(req->read_size) {
2538  DWORD written;
2539 
2540  b = WriteFile(req->hCacheFile, req->read_buf+req->read_pos, req->read_size, &written, NULL);
2541  if(!b)
2542  FIXME("WriteFile failed: %u\n", GetLastError());
2543 
2544  if(req->data_stream->vtbl->end_of_data(req->data_stream, req))
2545  commit_cache_entry(req);
2546  }
2547 }
BOOL WINAPI CreateUrlCacheEntryW(LPCWSTR lpszUrlName, DWORD dwExpectedFileSize, LPCWSTR lpszFileExtension, LPWSTR lpszFileName, DWORD dwReserved)
Definition: urlcache.c:2827
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:3898
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
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
ULONGLONG contentLength
Definition: internet.h:375
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
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:392
#define FILE_SHARE_READ
Definition: compat.h:125
HTTPHEADERW * custHeaders
Definition: internet.h:364
static const WCHAR szCache_Control[]
Definition: http.c:86
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:3871
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
#define CREATE_ALWAYS
Definition: disk.h:72
DWORD read_pos
Definition: internet.h:377
#define ARRAY_SIZE(a)
Definition: main.h:24
BYTE read_buf[READ_BUFFER_SIZE]
Definition: internet.h:379
static LPCWSTR file_name
Definition: protocol.c:147
#define CreateFileW
Definition: compat.h:408
static void commit_cache_entry(http_request_t *req)
Definition: http.c:2428
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:1918
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 861 of file http.c.

862 {
863  if (!authinfo) return;
864 
869 
870  heap_free(authinfo->auth_data);
873 }
#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 417 of file http.c.

418 {
419  stream->vtbl->destroy(stream);
420 }
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 3101 of file http.c.

3102 {
3103  DWORD res;
3104 
3105  TRACE("%p\n", req->netconn);
3106 
3107  if(!is_valid_netconn(req->netconn))
3108  return ERROR_NO_DATA;
3109 
3110  if(!strcmpW(req->verb, szHEAD))
3111  return ERROR_SUCCESS;
3112 
3114  res = req->data_stream->vtbl->drain_content(req->data_stream, req, blocking);
3116  return res;
3117 }
static const WCHAR szHEAD[]
Definition: http.c:77
#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:394
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 1673 of file http.c.

1674 {
1675  WCHAR *ret;
1676  UINT len, scheme_len = strlenW( scheme );
1677 
1678  /* scheme + space + base64 encoded data (3/2/1 bytes data -> 4 bytes of characters) */
1679  len = scheme_len + 1 + ((data_len + 2) * 4) / 3;
1680  if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1681  memcpy( ret, scheme, scheme_len * sizeof(WCHAR) );
1682  ret[scheme_len] = ' ';
1683  HTTP_EncodeBase64( data, data_len, ret + scheme_len + 1 );
1684  return ret;
1685 }
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:1567
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 2630 of file http.c.

2631 {
2632  return !req->read_size && req->data_stream->vtbl->end_of_data(req->data_stream, req);
2633 }
BOOL(* end_of_data)(data_stream_t *, http_request_t *)
Definition: http.c:392
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 1445 of file http.c.

1446 {
1447  WCHAR *ptr, **types = accept_types;
1448 
1449  if (!types) return;
1450  while ((ptr = *types))
1451  {
1452  heap_free( ptr );
1453  types++;
1454  }
1455  heap_free( accept_types );
1456 }
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().

◆ free_authorization_cache()

void free_authorization_cache ( void  )

Definition at line 1041 of file http.c.

1042 {
1043  authorizationData *ad, *sa_safe;
1044  basicAuthorizationData *basic, *basic_safe;
1045 
1047 
1049  {
1050  heap_free(basic->host);
1051  heap_free(basic->realm);
1052  heap_free(basic->authorization);
1053 
1054  list_remove(&basic->entry);
1055  heap_free(basic);
1056  }
1057 
1059  {
1060  heap_free(ad->host);
1061  heap_free(ad->scheme);
1062  heap_free(ad->user);
1063  heap_free(ad->password);
1064  heap_free(ad->domain);
1065  list_remove(&ad->entry);
1066  heap_free(ad);
1067  }
1068 
1070 }
static struct list basicAuthorizationCache
Definition: http.c:186
struct list entry
Definition: http.c:174
LPWSTR password
Definition: http.c:182
LPWSTR domain
Definition: http.c:178
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
LPWSTR scheme
Definition: http.c:177
struct list entry
Definition: http.c:164
LPWSTR host
Definition: http.c:176
LPWSTR user
Definition: http.c:180
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static struct list authorizationCache
Definition: http.c:187
static CRITICAL_SECTION authcache_cs
Definition: http.c:189

Referenced by InternetSetOptionW().

◆ get_host_header()

static WCHAR* get_host_header ( http_request_t req)
static

Definition at line 379 of file http.c.

380 {
382  WCHAR *ret = NULL;
383 
385  if ((header = HTTP_GetHeader( req, hostW ))) ret = heap_strdupW( header->lpszValue );
386  else ret = heap_strdupW( req->server->canon_host_port );
388  return ret;
389 }
static const WCHAR hostW[]
Definition: http.c:71
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:369
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:101

Referenced by HTTP_InsertAuthorization().

◆ get_redirect_url()

static WCHAR* get_redirect_url ( http_request_t request)
static

Definition at line 4089 of file http.c.

4090 {
4091  static WCHAR szHttp[] = {'h','t','t','p',0};
4092  static WCHAR szHttps[] = {'h','t','t','p','s',0};
4093  http_session_t *session = request->session;
4094  URL_COMPONENTSW urlComponents = { sizeof(urlComponents) };
4095  WCHAR *orig_url = NULL, *redirect_url = NULL, *combined_url = NULL;
4096  DWORD url_length = 0, res;
4097  BOOL b;
4098 
4099  url_length = 0;
4100  res = HTTP_HttpQueryInfoW(request, HTTP_QUERY_LOCATION, redirect_url, &url_length, NULL);
4102  redirect_url = heap_alloc(url_length);
4103  res = HTTP_HttpQueryInfoW(request, HTTP_QUERY_LOCATION, redirect_url, &url_length, NULL);
4104  }
4105  if(res != ERROR_SUCCESS) {
4106  heap_free(redirect_url);
4107  return NULL;
4108  }
4109 
4110  urlComponents.dwSchemeLength = 1;
4111  b = InternetCrackUrlW(redirect_url, url_length / sizeof(WCHAR), 0, &urlComponents);
4112  if(b && urlComponents.dwSchemeLength &&
4113  urlComponents.nScheme != INTERNET_SCHEME_HTTP && urlComponents.nScheme != INTERNET_SCHEME_HTTPS) {
4114  TRACE("redirect to non-http URL\n");
4115  return NULL;
4116  }
4117 
4118  urlComponents.lpszScheme = (request->hdr.dwFlags & INTERNET_FLAG_SECURE) ? szHttps : szHttp;
4119  urlComponents.dwSchemeLength = 0;
4120  urlComponents.lpszHostName = request->server->name;
4121  urlComponents.nPort = request->server->port;
4122  urlComponents.lpszUserName = session->userName;
4123  urlComponents.lpszUrlPath = request->path;
4124 
4125  b = InternetCreateUrlW(&urlComponents, 0, NULL, &url_length);
4127  orig_url = heap_alloc(url_length);
4128 
4129  /* convert from bytes to characters */
4130  url_length = url_length / sizeof(WCHAR) - 1;
4131  b = InternetCreateUrlW(&urlComponents, 0, orig_url, &url_length);
4132  }
4133 
4134  if(b) {
4135  url_length = 0;
4136  b = InternetCombineUrlW(orig_url, redirect_url, NULL, &url_length, ICU_ENCODE_SPACES_ONLY);
4138  combined_url = heap_alloc(url_length * sizeof(WCHAR));
4139  b = InternetCombineUrlW(orig_url, redirect_url, combined_url, &url_length, ICU_ENCODE_SPACES_ONLY);
4140  if(!b) {
4142  combined_url = NULL;
4143  }
4144  }
4145  }
4146 
4147  heap_free(orig_url);
4148  heap_free(redirect_url);
4149  return combined_url;
4150 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define INTERNET_FLAG_SECURE
Definition: wininet.h:71
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:3604
#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:4030
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:4307
struct object_header hdr
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:1644
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 273 of file http.c.

274 {
275  server_t *iter, *server = NULL;
276 
278 
280  if(iter->port == port && name.len == strlenW(iter->name) && !strncmpiW(iter->name, name.str, name.len)
281  && iter->is_https == is_https) {
282  server = iter;
284  break;
285  }
286  }
287 
288  if(!server && do_create) {
289  server = heap_alloc_zero(sizeof(*server));
290  if(server) {
291  server->ref = 2; /* list reference and return */
292  server->port = port;
293  server->is_https = is_https;
294  list_init(&server->conn_pool);
295  server->name = heap_strndupW(name.str, name.len);
296  if(server->name && process_host_port(server)) {
298  }else {
299  heap_free(server);
300  server = NULL;
301  }
302  }
303  }
304 
306 
307  return server;
308 }
static BOOL process_host_port(server_t *server)
Definition: http.c:246
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
__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:209
uint32_t entry
Definition: isohybrid.c:63
void server_addref(server_t *server)
Definition: http.c:221
WCHAR * name
Definition: internet.h:37
Definition: name.c:38
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
USHORT port
Definition: uri.c:228
static struct list connection_pool
Definition: http.c:218
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 4270 of file http.c.

4271 {
4272  LPCWSTR *t;
4273  LPWSTR str;
4274 
4275  for( t = list; *t ; t++ )
4276  len += strlenW( *t );
4277  len++;
4278 
4279  str = heap_alloc(len*sizeof(WCHAR));
4280  *str = 0;
4281 
4282  for( t = list; *t ; t++ )
4283  strcatW( str, *t );
4284 
4285  return str;
4286 }
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 5937 of file http.c.

5938 {
5939  DWORD i;
5940 
5941  EnterCriticalSection( &request->headers_section );
5942 
5943  for( i=0; i<request->nCustHeaders; i++)
5944  {
5945  if( !request->custHeaders[i].lpszField )
5946  continue;
5947  if( !request->custHeaders[i].lpszValue )
5948  continue;
5949  if ( request->custHeaders[i].wFlags & HDR_ISREQUEST )
5950  continue;
5952  i--;
5953  }
5954 
5955  LeaveCriticalSection( &request->headers_section );
5956 }
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:6358
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 5872 of file http.c.

5876 {
5878 
5879  TRACE("-->\n");
5880 
5881  if (!lpszServerName || !lpszServerName[0])
5882  return ERROR_INVALID_PARAMETER;
5883 
5884  assert( hIC->hdr.htype == WH_HINIT );
5885 
5887  if (!session)
5888  return ERROR_OUTOFMEMORY;
5889 
5890  /*
5891  * According to my tests. The name is not resolved until a request is sent
5892  */
5893 
5894  session->hdr.htype = WH_HHTTPSESSION;
5895  session->hdr.dwFlags = dwFlags;
5896  session->hdr.dwContext = dwContext;
5897  session->hdr.dwInternalFlags |= dwInternalFlags;
5898  session->hdr.decoding = hIC->hdr.decoding;
5899 
5900  WININET_AddRef( &hIC->hdr );
5901  session->appInfo = hIC;
5902  list_add_head( &hIC->hdr.children, &session->hdr.entry );
5903 
5904  session->hostName = heap_strdupW(lpszServerName);
5905  if (lpszUserName && lpszUserName[0])
5906  session->userName = heap_strdupW(lpszUserName);
5907  session->password = heap_strdupW(lpszPassword);
5908  session->hostPort = serverPort;
5910  session->send_timeout = 0;
5911  session->receive_timeout = 0;
5912 
5913  /* Don't send a handle created callback if this handle was created with InternetOpenUrl */
5914  if (!(session->hdr.dwInternalFlags & INET_OPENURL))
5915  {
5916  INTERNET_SendCallback(&hIC->hdr, dwContext,
5918  sizeof(HINTERNET));
5919  }
5920 
5921 /*
5922  * an INTERNET_STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on
5923  * windows
5924  */
5925 
5926  TRACE("%p --> %p\n", hIC, session);
5927 
5928  *ret = session->hdr.hInternet;
5929  return ERROR_SUCCESS;
5930 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
struct list children
Definition: internet.h:287
#define assert(x)
Definition: debug.h:53
_In_opt_ LPSTR _In_opt_ LPSTR lpszPassword
Definition: winbase.h:2668
int receive_timeout
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) DECLSPEC_HIDDEN
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
smooth NULL
Definition: ftsmooth.c:416
object_header_t * WININET_AddRef(object_header_t *info)
Definition: internet.c:177
#define TRACE(s)
Definition: solgame.cpp:4
struct object_header hdr
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:111
DWORD connect_timeout
Definition: internet.h:299
static const object_vtbl_t HTTPSESSIONVtbl
Definition: http.c:5850
object_header_t hdr
Definition: internet.h:292
#define INET_OPENURL
Definition: internet.h:244
int connect_timeout
int send_timeout
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
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 1849 of file http.c.

1850 {
1851  static const WCHAR protoHttp[] = { 'h','t','t','p',0 };
1852  static const WCHAR szHttp[] = { 'h','t','t','p',':','/','/',0 };
1853  static WCHAR szNul[] = { 0 };
1854  URL_COMPONENTSW UrlComponents = { sizeof(UrlComponents) };
1855  server_t *new_server = NULL;
1856  WCHAR *proxy;
1857 
1858  proxy = INTERNET_FindProxyForProtocol(hIC->proxy, protoHttp);
1859  if(!proxy)
1860  return FALSE;
1862  proxy, strlenW(szHttp), szHttp, strlenW(szHttp))) {
1863  WCHAR *proxy_url = heap_alloc(strlenW(proxy)*sizeof(WCHAR) + sizeof(szHttp));
1864  if(!proxy_url) {
1865  heap_free(proxy);
1866  return FALSE;
1867  }
1868  strcpyW(proxy_url, szHttp);
1869  strcatW(proxy_url, proxy);
1870  heap_free(proxy);
1871  proxy = proxy_url;
1872  }
1873 
1874  UrlComponents.dwHostNameLength = 1;
1875  if(InternetCrackUrlW(proxy, 0, 0, &UrlComponents) && UrlComponents.dwHostNameLength) {
1876  if( !request->path )
1877  request->path = szNul;
1878 
1879  new_server = get_server(substr(UrlComponents.lpszHostName, UrlComponents.dwHostNameLength),
1880  UrlComponents.nPort, UrlComponents.nScheme == INTERNET_SCHEME_HTTPS, TRUE);
1881  }
1882  heap_free(proxy);
1883  if(!new_server)
1884  return FALSE;
1885 
1886  request->proxy = new_server;
1887 
1888  TRACE("proxy server=%s port=%d\n", debugstr_w(new_server->name), new_server->port);
1889  return TRUE;
1890 }
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:273
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:1644
static substr_t substr(const WCHAR *str, size_t len)
Definition: internet.h:204
WCHAR * INTERNET_FindProxyForProtocol(LPCWSTR szProxy, LPCWSTR proto)
Definition: internet.c:392
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 1623 of file http.c.

1624 {
1625  unsigned int n = 0;
1626 
1627  while(*base64)
1628  {
1629  signed char in[4];
1630 
1631  if (base64[0] >= ARRAY_SIZE(HTTP_Base64Dec) ||
1632  ((in[0] = HTTP_Base64Dec[base64[0]]) == -1) ||
1633  base64[1] >= ARRAY_SIZE(HTTP_Base64Dec) ||
1634  ((in[1] = HTTP_Base64Dec[base64[1]]) == -1))
1635  {
1636  WARN("invalid base64: %s\n", debugstr_w(base64));
1637  return 0;
1638  }
1639  if (bin)
1640  bin[n] = (unsigned char) (in[0] << 2 | in[1] >> 4);
1641  n++;
1642 
1643  if ((base64[2] == '=') && (base64[3] == '='))
1644  break;
1645  if (base64[2] > ARRAY_SIZE(HTTP_Base64Dec) ||
1646  ((in[2] = HTTP_Base64Dec[base64[2]]) == -1))
1647  {
1648  WARN("invalid base64: %s\n", debugstr_w(&base64[2]));
1649  return 0;
1650  }
1651  if (bin)
1652  bin[n] = (unsigned char) (in[1] << 4 | in[2] >> 2);
1653  n++;
1654 
1655  if (base64[3] == '=')
1656  break;
1657  if (base64[3] > ARRAY_SIZE(HTTP_Base64Dec) ||
1658  ((in[3] = HTTP_Base64Dec[base64[3]]) == -1))
1659  {
1660  WARN("invalid base64: %s\n", debugstr_w(&base64[3]));
1661  return 0;
1662  }
1663  if (bin)
1664  bin[n] = (unsigned char) (((in[2] << 6) & 0xc0) | in[3]);
1665  n++;
1666 
1667  base64 += 4;
1668  }
1669 
1670  return n;
1671 }
#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
GLuint in
Definition: glext.h:9616
#define ARRAY_SIZE(a)
Definition: main.h:24
static struct _PeImage bin
static const signed char HTTP_Base64Dec[]
Definition: http.c:1608

Referenced by HTTP_DoAuthorization().

◆ HTTP_DeleteCustomHeader()

static BOOL HTTP_DeleteCustomHeader ( http_request_t req,
DWORD  index 
)
static

Definition at line 6358 of file http.c.

6359 {
6360  if( request->nCustHeaders <= 0 )
6361  return FALSE;
6362  if( index >= request->nCustHeaders )
6363  return FALSE;
6364  request->nCustHeaders--;
6365 
6366  heap_free(request->custHeaders[index].lpszField);
6367  heap_free(request->custHeaders[index].lpszValue);
6368 
6369  memmove( &request->custHeaders[index], &request->custHeaders[index+1],
6370  (request->nCustHeaders - index)* sizeof(HTTPHEADERW) );
6371  memset( &request->custHeaders[request->nCustHeaders], 0, sizeof(HTTPHEADERW) );
6372 
6373  return TRUE;
6374 }
#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 1072 of file http.c.

1076 {
1077  SECURITY_STATUS sec_status;
1078  struct HttpAuthInfo *pAuthInfo = *ppAuthInfo;
1079  BOOL first = FALSE;
1080  LPWSTR szRealm = NULL;
1081 
1082  TRACE("%s\n", debugstr_w(pszAuthValue));
1083 
1084  if (!pAuthInfo)
1085  {
1086  TimeStamp exp;
1087 
1088  first = TRUE;
1089  pAuthInfo = heap_alloc(sizeof(*pAuthInfo));
1090  if (!pAuthInfo)
1091  return FALSE;
1092 
1093  SecInvalidateHandle(&pAuthInfo->cred);
1094  SecInvalidateHandle(&pAuthInfo->ctx);
1095  memset(&pAuthInfo->exp, 0, sizeof(pAuthInfo->exp));
1096  pAuthInfo->attr = 0;
1097  pAuthInfo->auth_data = NULL;
1098  pAuthInfo->auth_data_len = 0;
1099  pAuthInfo->finished = FALSE;
1100 
1101  if (is_basic_auth_value(pszAuthValue,NULL))
1102  {
1103  static const WCHAR szBasic[] = {'B','a','s','i','c',0};
1104  pAuthInfo->scheme = heap_strdupW(szBasic);
1105  if (!pAuthInfo->scheme)
1106  {
1107  heap_free(pAuthInfo);
1108  return FALSE;
1109  }
1110  }
1111  else
1112  {
1113  PVOID pAuthData;
1114  SEC_WINNT_AUTH_IDENTITY_W nt_auth_identity;
1115 
1116  pAuthInfo->scheme = heap_strdupW(pszAuthValue);
1117  if (!pAuthInfo->scheme)
1118  {
1119  heap_free(pAuthInfo);
1120  return FALSE;
1121  }
1122 
1123  if (domain_and_username)
1124  {
1125  WCHAR *user = strchrW(domain_and_username, '\\');
1126  WCHAR *domain = domain_and_username;
1127 
1128  /* FIXME: make sure scheme accepts SEC_WINNT_AUTH_IDENTITY before calling AcquireCredentialsHandle */
1129 
1130  pAuthData = &nt_auth_identity;
1131 
1132  if (user) user++;
1133  else
1134  {
1135  user = domain_and_username;
1136  domain = NULL;
1137  }
1138 
1139  nt_auth_identity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
1140  nt_auth_identity.User = user;
1141  nt_auth_identity.UserLength = strlenW(nt_auth_identity.User);
1142  nt_auth_identity.Domain = domain;
1143  nt_auth_identity.DomainLength = domain ? user - domain - 1 : 0;
1144  nt_auth_identity.Password = password;
1145  nt_auth_identity.PasswordLength = strlenW(nt_auth_identity.Password);
1146 
1147  cache_authorization(host, pAuthInfo->scheme, &nt_auth_identity);
1148  }
1149  else if(retrieve_cached_authorization(host, pAuthInfo->scheme, &nt_auth_identity))
1150  pAuthData = &nt_auth_identity;
1151  else
1152  /* use default credentials */
1153  pAuthData = NULL;
1154 
1155  sec_status = AcquireCredentialsHandleW(NULL, pAuthInfo->scheme,
1157  pAuthData, NULL,
1158  NULL, &pAuthInfo->cred,
1159  &exp);
1160 
1161  if(pAuthData && !domain_and_username) {
1162  heap_free(nt_auth_identity.User);
1163  heap_free(nt_auth_identity.Domain);
1164  heap_free(nt_auth_identity.Password);
1165  }
1166 
1167  if (sec_status == SEC_E_OK)
1168  {
1169  PSecPkgInfoW sec_pkg_info;
1170  sec_status = QuerySecurityPackageInfoW(pAuthInfo->scheme, &sec_pkg_info);
1171  if (sec_status == SEC_E_OK)
1172  {
1173  pAuthInfo->max_token = sec_pkg_info->cbMaxToken;
1174  FreeContextBuffer(sec_pkg_info);
1175  }
1176  }
1177  if (sec_status != SEC_E_OK)
1178  {
1179  WARN("AcquireCredentialsHandleW for scheme %s failed with error 0x%08x\n",
1180  debugstr_w(pAuthInfo->scheme), sec_status);
1181  heap_free(pAuthInfo->scheme);
1182  heap_free(pAuthInfo);
1183  return FALSE;
1184  }
1185  }
1186  *ppAuthInfo = pAuthInfo;
1187  }
1188  else if (pAuthInfo->finished)
1189  return FALSE;
1190 
1191  if ((strlenW(pszAuthValue) < strlenW(pAuthInfo->scheme)) ||
1192  strncmpiW(pszAuthValue, pAuthInfo->scheme, strlenW(pAuthInfo->scheme)))
1193  {
1194  ERR("authentication scheme changed from %s to %s\n",
1195  debugstr_w(pAuthInfo->scheme), debugstr_w(pszAuthValue));
1196  return FALSE;
1197  }
1198 
1199  if (is_basic_auth_value(pszAuthValue,&szRealm))
1200  {
1201  int userlen;
1202  int passlen;
1203  char *auth_data = NULL;
1204  UINT auth_data_len = 0;
1205 
1206  TRACE("basic authentication realm %s\n",debugstr_w(szRealm));
1207 
1208  if (!domain_and_username)
1209  {
1210  if (host && szRealm)
1212  if (auth_data_len == 0)
1213  {
1214  heap_free(szRealm);
1215  return FALSE;
1216  }
1217  }
1218  else
1219  {
1220  userlen = WideCharToMultiByte(CP_UTF8, 0, domain_and_username, lstrlenW(domain_and_username), NULL, 0, NULL, NULL);
1222 
1223  /* length includes a nul terminator, which will be re-used for the ':' */
1224  auth_data = heap_alloc(userlen + 1 + passlen);
1225  if (!auth_data)
1226  {
1227  heap_free(szRealm);
1228  return FALSE;
1229  }
1230 
1231  WideCharToMultiByte(CP_UTF8, 0, domain_and_username, -1, auth_data, userlen, NULL, NULL);
1232  auth_data[userlen] = ':';
1233  WideCharToMultiByte(CP_UTF8, 0, password, -1, &auth_data[userlen+1], passlen, NULL, NULL);
1234  auth_data_len = userlen + 1 + passlen;
1235  if (host && szRealm)
1237  }
1238 
1239  pAuthInfo->auth_data = auth_data;
1240  pAuthInfo->auth_data_len = auth_data_len;
1241  pAuthInfo->finished = TRUE;
1242  heap_free(szRealm);
1243  return TRUE;
1244  }
1245  else
1246  {
1247  LPCWSTR pszAuthData;
1248  SecBufferDesc out_desc, in_desc;
1249  SecBuffer out, in;
1250  unsigned char *buffer;
1253 
1254  in.BufferType = SECBUFFER_TOKEN;
1255  in.cbBuffer = 0;
1256  in.pvBuffer = NULL;
1257 
1258  in_desc.ulVersion = 0;
1259  in_desc.cBuffers = 1;
1260  in_desc.pBuffers = &in;
1261 
1262  pszAuthData = pszAuthValue + strlenW(pAuthInfo->scheme);
1263  if (*pszAuthData == ' ')
1264  {
1265  pszAuthData++;
1266  in.cbBuffer = HTTP_DecodeBase64(pszAuthData, NULL);
1267  in.pvBuffer = heap_alloc(in.cbBuffer);
1268  HTTP_DecodeBase64(pszAuthData, in.pvBuffer);
1269  }
1270 
1271  buffer = heap_alloc(pAuthInfo->max_token);
1272 
1273  out.BufferType = SECBUFFER_TOKEN;
1274  out.cbBuffer = pAuthInfo->max_token;
1275  out.pvBuffer = buffer;
1276 
1277  out_desc.ulVersion = 0;
1278  out_desc.cBuffers = 1;
1279  out_desc.pBuffers = &out;
1280 
1281  sec_status = InitializeSecurityContextW(first ? &pAuthInfo->cred : NULL,
1282  first ? NULL : &pAuthInfo->ctx,
1283  first ? request->server->name : NULL,
1284  context_req, 0, SECURITY_NETWORK_DREP,
1285  in.pvBuffer ? &in_desc : NULL,
1286  0, &pAuthInfo->ctx, &out_desc,
1287  &pAuthInfo->attr, &pAuthInfo->exp);
1288  if (sec_status == SEC_E_OK)
1289  {
1290  pAuthInfo->finished = TRUE;
1291  pAuthInfo->auth_data = out.pvBuffer;
1292  pAuthInfo->auth_data_len = out.cbBuffer;
1293  TRACE("sending last auth packet\n");
1294  }
1295  else if (sec_status == SEC_I_CONTINUE_NEEDED)
1296  {
1297  pAuthInfo->auth_data = out.pvBuffer;
1298  pAuthInfo->auth_data_len = out.cbBuffer;
1299  TRACE("sending next auth packet\n");
1300  }
1301  else
1302  {
1303  ERR("InitializeSecurityContextW returned error 0x%08x\n", sec_status);
1304  heap_free(out.pvBuffer);
1305  destroy_authinfo(pAuthInfo);
1306  *ppAuthInfo = NULL;
1307  return FALSE;
1308  }
1309  }
1310 
1311  return TRUE;
1312 }
static BOOL is_basic_auth_value(LPCWSTR pszAuthValue, LPWSTR *pszRealm)
Definition: http.c:825
unsigned int auth_data_len
Definition: http.c:157
CtxtHandle ctx
Definition: http.c:152
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:278
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:168
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:1623
char * host
Definition: whois.c:55
GLuint buffer
Definition: glext.h:5915
#define ISC_REQ_DELEGATE
Definition: sspi.h:349
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define lstrlenW
Definition: compat.h:415
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
Definition: cookie.c:41
static void cache_basic_authorization(LPWSTR host, LPWSTR realm, LPSTR auth_data, UINT auth_data_len)
Definition: http.c:912
#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:952
#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:153
static WCHAR * heap_strdupW(const WCHAR *str)
Definition: propsheet.c:178
#define debugstr_w
Definition: kernel32.h:32
LPWSTR scheme
Definition: http.c:150
static void cache_authorization(LPWSTR host, LPWSTR scheme, SEC_WINNT_AUTH_IDENTITY_W *nt_auth_identity)
Definition: http.c:989
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:861
#define TRACE(s)
Definition: solgame.cpp:4
BOOL finished
Definition: http.c:158
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:155
static UINT retrieve_cached_basic_authorization(http_request_t *req, const WCHAR *host, const WCHAR *realm, char **auth_data)
Definition: http.c:875
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
ULONG attr
Definition: http.c:154
#define SECBUFFER_TOKEN
Definition: sspi.h:148
#define ISC_REQ_USE_DCE_STYLE
Definition: sspi.h:358
#define SECURITY_NETWORK_DREP
Definition: sspi.h:461
void * auth_data
Definition: http.c:156
#define SEC_E_OK
Definition: winerror.h:2356
#define ISC_REQ_CONNECTION
Definition: sspi.h:360
#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:16038
#define ISC_REQ_MUTUAL_AUTH
Definition: sspi.h:350
Definition: tftpd.h:85
CredHandle cred
Definition: http.c:151
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
ULONG cBuffers
Definition: sspi.h:169
#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 1780 of file http.c.

1781 {
1782  static const WCHAR localW[] = { '<','l','o','c','a','l','>',0 };
1783  const WCHAR *dot, *ptr;
1784  int len;
1785 
1786  if(domain.len == ARRAY_SIZE(localW)-1 && !strncmpiW(domain.str, localW, domain.len) && !strchrW(server, '.' ))
1787  return TRUE;
1788 
1789  if(domain.len && *domain.str != '*')
1790  return domain.len == strlenW(server) && !strncmpiW(server, domain.str, domain.len);
1791 
1792  if(domain.len < 2 || domain.str[1] != '.')
1793  return FALSE;
1794 
1795  /* For a hostname to match a wildcard, the last domain must match
1796  * the wildcard exactly. E.g. if the wildcard is *.a.b, and the
1797  * hostname is www.foo.a.b, it matches, but a.b does not.
1798  */
1799  dot = strchrW(server, '.');
1800  if(!dot)
1801  return FALSE;
1802 
1803  len = strlenW(dot + 1);
1804  if(len < domain.len - 2)
1805  return FALSE;
1806 
1807  /* The server's domain is longer than the wildcard, so it
1808  * could be a subdomain. Compare the last portion of the
1809  * server's domain.
1810  */
1811  ptr = dot + 1 + len - domain.len + 2;
1812  if(!strncmpiW(ptr, domain.str+2, domain.len-2))
1813  /* This is only a match if the preceding character is
1814  * a '.', i.e. that it is a matching domain. E.g.
1815  * if domain is '*.b.c' and server is 'www.ab.c' they
1816  * do not match.
1817  */
1818  return *(ptr - 1) == '.';
1819 
1820  return len == domain.len-2 && !strncmpiW(dot + 1, domain.str + 2, len);
1821 }
#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
Definition: cookie.c:41
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by HTTP_ShouldBypassProxy().

◆ HTTP_EncodeBase64()

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

Definition at line 1567 of file http.c.

1568 {
1569  UINT n = 0, x;
1570  static const CHAR HTTP_Base64Enc[] =
1571  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1572 
1573  while( len > 0 )
1574  {
1575  /* first 6 bits, all from bin[0] */
1576  base64[n++] = HTTP_Base64Enc[(bin[0] & 0xfc) >> 2];
1577  x = (bin[0] & 3) << 4;
1578 
1579  /* next 6 bits, 2 from bin[0] and 4 from bin[1] */
1580  if( len == 1 )
1581  {
1582  base64[n++] = HTTP_Base64Enc[x];
1583  base64[n++] = '=';
1584  base64[n++] = '=';
1585  break;
1586  }
1587  base64[n++] = HTTP_Base64Enc[ x | ( (bin[1]&0xf0) >> 4 ) ];
1588  x = ( bin[1] & 0x0f ) << 2;
1589 
1590  /* next 6 bits 4 from bin[1] and 2 from bin[2] */
1591  if( len == 2 )
1592  {
1593  base64[n++] = HTTP_Base64Enc[x];
1594  base64[n++] = '=';
1595  break;
1596  }
1597  base64[n++] = HTTP_Base64Enc[ x | ( (bin[2]&0xc0 ) >> 6 ) ];
1598 
1599  /* last 6 bits, all from bin [2] */
1600  base64[n++] = HTTP_Base64Enc[ bin[2] & 0x3f ];
1601  bin += 3;
1602  len -= 3;
1603  }
1604  base64[n] = 0;
1605  return n;
1606 }
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 611 of file http.c.

612 {
613  static const WCHAR szSlash[] = { '/',0 };
614  static const WCHAR szHttp[] = { 'h','t','t','p',':','/','/', 0 };
615 
616  /* If we don't have a path we set it to root */
617  if (NULL == request->path)
618  request->path = heap_strdupW(szSlash);
619  else /* remove \r and \n*/
620  {
621  int nLen = strlenW(request->path);
622  while ((nLen >0 ) && ((request->path[nLen-1] == '\r')||(request->path[nLen-1] == '\n')))
623  {
624  nLen--;
625  request->path[nLen]='\0';
626  }
627  /* Replace '\' with '/' */
628  while (nLen>0) {
629  nLen--;
630  if (request->path[nLen] == '\\') request->path[nLen]='/';
631  }
632  }
633 
635  request->path, strlenW(request->path), szHttp, strlenW(szHttp) )
636  && request->path[0] != '/') /* not an absolute path ?? --> fix it !! */
637  {
638  WCHAR *fixurl = heap_alloc((strlenW(request->path) + 2)*sizeof(WCHAR));
639  *fixurl = '/';
640  strcpyW(fixurl + 1, request->path);
641  heap_free( request->path );
642  request->path = fixurl;
643  }
644 }
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 604 of file http.c.

605 {
606  int i;
607  for (i = 0; token_array[i]; i++) heap_free(token_array[i]);
608  heap_free(token_array);
609 }
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 6288 of file http.c.

6290 {
6291  DWORD index;
6292 
6293  TRACE("%s, %d, %d\n", debugstr_w(lpszField), requested_index, request_only);
6294 
6295  for (index = 0; index < request->nCustHeaders; index++)
6296  {
6297  if (strcmpiW(request->custHeaders[index].lpszField, lpszField))
6298  continue;
6299 
6300  if (request_only && !(request->custHeaders[index].wFlags & HDR_ISREQUEST))
6301  continue;
6302 
6303  if (!request_only && (request->custHeaders[index].wFlags & HDR_ISREQUEST))
6304  continue;
6305 
6306  if (requested_index == 0)
6307  break;
6308  requested_index --;
6309  }
6310 
6311  if (index >= request->nCustHeaders)
6312  index = -1;
6313 
6314  TRACE("Return: %d\n", index);
6315  return index;
6316 }
#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 369 of file http.c.

370 {
371  int HeaderIndex = 0;
372  HeaderIndex = HTTP_GetCustomHeaderIndex(req, head, 0, TRUE);
373  if (HeaderIndex == -1)
374  return NULL;
375  else
376  return &req->custHeaders[HeaderIndex];
377 }
#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 5968 of file http.c.

5969 {
5970  INT cbreaks = 0;
5972  DWORD buflen = MAX_REPLY_LEN;
5973  INT rc = 0;
5974  char bufferA[MAX_REPLY_LEN];
5975  LPWSTR status_code = NULL, status_text = NULL;
5977  BOOL codeHundred = FALSE;
5978 
5979  TRACE("-->\n");
5980 
5982  goto lend;
5983 
5984  /* clear old response headers (eg. from a redirect response) */
5986 
5988  do {
5989  /*
5990  * We should first receive 'HTTP/1.x nnn OK' where nnn is the status code.
5991  */
5992  buflen = MAX_REPLY_LEN;
5993  if ((res = read_line(request, bufferA, &buflen)))
5994  goto lend;
5995 
5996  if (!buflen) goto lend;
5997 
5998  rc += buflen;
5999  MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
6000  /* check is this a status code line? */
6001  if (!strncmpW(buffer, g_szHttp1_0, 4))
6002  {
6003  /* split the version from the status code */
6004  status_code = strchrW( buffer, ' ' );
6005  if( !status_code )
6006  goto lend;
6007  *status_code++=0;
6008 
6009  /* split the status code from the status text */
6010  status_text = strchrW( status_code, ' ' );
6011  if( status_text )
6012  *status_text++=0;
6013 
6014  request->status_code = atoiW(status_code);
6015 
6016  TRACE("version [%s] status code [%s] status text [%s]\n",
6017  debugstr_w(buffer), debugstr_w(status_code), debugstr_w(status_text) );
6018 
6019  codeHundred = request->status_code == HTTP_STATUS_CONTINUE;
6020  }
6021  else if (!codeHundred)
6022  {
6023  WARN("No status line at head of response (%s)\n", debugstr_w(buffer));
6024 
6026  heap_free(request->statusText);
6027 
6028  request->status_code = HTTP_STATUS_OK;
6030  request->statusText = heap_strdupW(szOK);
6031 
6032  goto lend;
6033  }
6034  } while (codeHundred);
6035 
6036  /* Add status code */
6039 
6041  heap_free(request->statusText);
6042 
6044  request->statusText = heap_strdupW(status_text ? status_text : emptyW);
6045 
6046  /* Restore the spaces */
6047  *(status_code-1) = ' ';
6048  if (status_text)
6049  *(status_text-1) = ' ';
6050 
6051  /* Parse each response line */
6052  do
6053  {
6054  buflen = MAX_REPLY_LEN;
6055  if (!read_line(request, bufferA, &buflen) && buflen)
6056  {
6057  LPWSTR * pFieldAndValue;
6058 
6059  TRACE("got line %s, now interpreting\n", debugstr_a(bufferA));
6060 
6061  if (!bufferA[0]) break;
6062  MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
6063 
6064  pFieldAndValue = HTTP_InterpretHttpHeader(buffer);
6065  if (pFieldAndValue)
6066  {
6067  HTTP_ProcessHeader(request, pFieldAndValue[0], pFieldAndValue[1],
6069  HTTP_FreeTokens(pFieldAndValue);
6070  }
6071  }
6072  else
6073  {
6074  cbreaks++;
6075  if (cbreaks >= 2)
6076  break;
6077  }
6078  }while(1);
6079 
6080  res = ERROR_SUCCESS;
6081 
6082 lend:
6083 
6084  *len = rc;
6085  TRACE("<--\n");
6086  return res;
6087 }
int receive_timeout
static const WCHAR g_szHttp1_0[]
Definition: http.c:68
#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:5937
WCHAR * version
GLuint buffer
Definition: glext.h:5915
int32_t INT
Definition: typedefs.h:56
#define ERROR_HTTP_INVALID_SERVER_RESPONSE
Definition: wininet.h:2060
WINE_UNICODE_INLINE int strncmpW(const WCHAR *str1, const WCHAR *str2, int n)
Definition: unicode.h:235
#define MAX_REPLY_LEN
Definition: request.c:2568
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR emptyW[]
Definition: http.c:133
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:6153
static DWORD read_line(http_request_t *req, LPSTR buffer, DWORD *len)
Definition: http.c:2580
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:74
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:6099
GLenum GLsizei len
Definition: glext.h:6722
BOOL is_valid_netconn(netconn_t *) DECLSPEC_HIDDEN
struct netconn * netconn
#define MultiByteToWideChar
Definition: compat.h:100
Definition: tftpd.h:85
static void HTTP_FreeTokens(LPWSTR *token_array)
Definition: http.c:604
#define HTTP_STATUS_CONTINUE
Definition: winhttp.h:238
#define HTTP_ADDHDR_FLAG_ADD
Definition: http.c:139
GLuint res
Definition: glext.h:9613
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static const WCHAR szOK[]
Definition: http.c:70
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 4156 of file http.c.

4157 {
4158  URL_COMPONENTSW urlComponents = { sizeof(urlComponents) };
4159  http_session_t *session = request->session;
4160  size_t url_len = strlenW(url);
4161 
4162  if(url[0] == '/')
4163  {
4164  /* if it's an absolute path, keep the same session info */
4165  urlComponents.lpszUrlPath = url;
4166  urlComponents.dwUrlPathLength = url_len;
4167  }
4168  else
4169  {
4170  urlComponents.dwHostNameLength = 1;
4171  urlComponents.dwUserNameLength = 1;
4172  urlComponents.dwUrlPathLength = 1;
4173  if(!InternetCrackUrlW(url, url_len, 0, &urlComponents))
4174  return INTERNET_GetLastError();
4175 
4176  if(!urlComponents.dwHostNameLength)
4178  }
4179 
4181  url, (url_len + 1) * sizeof(WCHAR));
4182 
4183  if(urlComponents.dwHostNameLength) {
4184  BOOL custom_port = FALSE;
4185  substr_t host;
4186 
4187  if(urlComponents.nScheme == INTERNET_SCHEME_HTTP) {
4188  if(request->hdr.dwFlags & INTERNET_FLAG_SECURE) {
4189  TRACE("redirect from secure page to non-secure page\n");
4190  /* FIXME: warn about from secure redirect to non-secure page */
4191  request->hdr.dwFlags &= ~INTERNET_FLAG_SECURE;
4192  }
4193 
4194  custom_port = urlComponents.nPort != INTERNET_DEFAULT_HTTP_PORT;
4195  }else if(urlComponents.nScheme == INTERNET_SCHEME_HTTPS) {
4196  if(!(request->hdr.dwFlags & INTERNET_FLAG_SECURE)) {
4197  TRACE("redirect from non-secure page to secure page\n");
4198  /* FIXME: notify about redirect to secure page */
4199  request->hdr.dwFlags |= INTERNET_FLAG_SECURE;
4200  }
4201