ReactOS  0.4.14-dev-583-g2a1ba2c
request.c File Reference
#include "config.h"
#include "ws2tcpip.h"
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "ole2.h"
#include "initguid.h"
#include "httprequest.h"
#include "httprequestid.h"
#include "schannel.h"
#include "winhttp.h"
#include "wine/debug.h"
#include "winhttp_private.h"
Include dependency graph for request.c:

Go to the source code of this file.

Classes

struct  winhttp_request
 
struct  stream
 

Macros

#define COBJMACROS
 
#define DEFAULT_KEEP_ALIVE_TIMEOUT   30000
 
#define QUERY_MODIFIER_MASK   (WINHTTP_QUERY_FLAG_REQUEST_HEADERS | WINHTTP_QUERY_FLAG_SYSTEMTIME | WINHTTP_QUERY_FLAG_NUMBER)
 
#define ESCAPE_MASK_DEFAULT
 
#define ESCAPE_MASK_PERCENT   (ESCAPE_FLAG_PERCENT | ESCAPE_MASK_DEFAULT)
 
#define ESCAPE_MASK_DISABLE   (ESCAPE_FLAG_SPACE | ESCAPE_FLAG_8BIT | ESCAPE_FLAG_STRIP_CRLF)
 
#define MAX_REPLY_LEN   1460
 
#define INITIAL_HEADER_BUFFER_LEN   512
 

Enumerations

enum  escape_flags {
  ESCAPE_FLAG_NON_PRINTABLE = 0x01, ESCAPE_FLAG_SPACE = 0x02, ESCAPE_FLAG_PERCENT = 0x04, ESCAPE_FLAG_UNSAFE = 0x08,
  ESCAPE_FLAG_DEL = 0x10, ESCAPE_FLAG_8BIT = 0x20, ESCAPE_FLAG_STRIP_CRLF = 0x40
}
 
enum  request_state {
  REQUEST_STATE_INITIALIZED, REQUEST_STATE_CANCELLED, REQUEST_STATE_OPEN, REQUEST_STATE_SENT,
  REQUEST_STATE_RESPONSE_RECEIVED
}
 
enum  type_id {
  INetFwAuthorizedApplication_tid, INetFwAuthorizedApplications_tid, INetFwMgr_tid, INetFwOpenPort_tid,
  INetFwOpenPorts_tid, INetFwPolicy_tid, INetFwPolicy2_tid, INetFwProfile_tid,
  INetFwRules_tid, IUPnPNAT_tid, last_tid, ISWbemLocator_tid,
  ISWbemObject_tid, ISWbemObjectSet_tid, ISWbemProperty_tid, ISWbemPropertySet_tid,
  ISWbemServices_tid, ISWbemSecurity_tid, last_tid, IWinHttpRequest_tid,
  last_tid
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (winhttp)
 
static struct task_headerdequeue_task (struct request *request)
 
static void CALLBACK task_proc (TP_CALLBACK_INSTANCE *instance, void *ctx)
 
static BOOL queue_task (struct task_header *task)
 
static void free_header (struct header *header)
 
static BOOL valid_token_char (WCHAR c)
 
static struct headerparse_header (const WCHAR *string)
 
static int get_header_index (struct request *request, const WCHAR *field, int requested_index, BOOL request_only)
 
static BOOL insert_header (struct request *request, struct header *header)
 
static BOOL delete_header (struct request *request, DWORD index)
 
BOOL process_header (struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only)
 
BOOL add_request_headers (struct request *request, const WCHAR *headers, DWORD len, DWORD flags)
 
BOOL WINAPI WinHttpAddRequestHeaders (HINTERNET hrequest, LPCWSTR headers, DWORD len, DWORD flags)
 
static WCHARbuild_absolute_request_path (struct request *request, const WCHAR **path)
 
static WCHARbuild_request_string (struct request *request)
 
static BOOL query_headers (struct request *request, DWORD level, const WCHAR *name, void *buffer, DWORD *buflen, DWORD *index)
 
BOOL WINAPI WinHttpQueryHeaders (HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
 
static enum auth_scheme scheme_from_flag (DWORD flag)
 
static DWORD auth_scheme_from_header (const WCHAR *header)
 
static BOOL query_auth_schemes (struct request *request, DWORD level, DWORD *supported, DWORD *first)
 
BOOL WINAPI WinHttpQueryAuthSchemes (HINTERNET hrequest, LPDWORD supported, LPDWORD first, LPDWORD target)
 
static UINT encode_base64 (const char *bin, unsigned int len, WCHAR *base64)
 
static char decode_char (WCHAR c)
 
static unsigned int decode_base64 (const WCHAR *base64, unsigned int len, char *buf)
 
static struct authinfoalloc_authinfo (void)
 
void destroy_authinfo (struct authinfo *authinfo)
 
static BOOL get_authvalue (struct request *request, DWORD level, DWORD scheme, WCHAR *buffer, DWORD len)
 
static BOOL do_authorization (struct request *request, DWORD target, DWORD scheme_flag)
 
static WCHARbuild_proxy_connect_string (struct request *request)
 
static BOOL read_reply (struct request *request)
 
static BOOL secure_proxy_connect (struct request *request)
 
static WCHARaddr_to_str (struct sockaddr_storage *addr)
 
void release_host (struct hostdata *host)
 
static void CALLBACK connection_collector (TP_CALLBACK_INSTANCE *instance, void *ctx)
 
static void cache_connection (struct netconn *netconn)
 
static DWORD map_secure_protocols (DWORD mask)
 
static BOOL ensure_cred_handle (struct request *request)
 
static BOOL open_connection (struct request *request)
 
void close_connection (struct request *request)
 
static BOOL add_host_header (struct request *request, DWORD modifier)
 
static void clear_response_headers (struct request *request)
 
static void remove_data (struct request *request, int count)
 
static BOOL read_more_data (struct request *request, int maxlen, BOOL notify)
 
static BOOL discard_eol (struct request *request, BOOL notify)
 
static BOOL start_next_chunk (struct request *request, BOOL notify)
 
static BOOL refill_buffer (struct request *request, BOOL notify)
 
static void finished_reading (struct request *request)
 
static DWORD get_available_data (struct request *request)
 
static BOOL end_of_read_data (struct request *request)
 
static BOOL read_data (struct request *request, void *buffer, DWORD size, DWORD *read, BOOL async)
 
static void drain_content (struct request *request)
 
static BOOL need_escape (char ch, enum escape_flags flags)
 
static DWORD escape_string (const char *src, DWORD len, char *dst, enum escape_flags flags)
 
static DWORD str_to_wire (const WCHAR *src, int src_len, char *dst, enum escape_flags flags)
 
static charbuild_wire_path (struct request *request, DWORD *ret_len)
 
static charbuild_wire_request (struct request *request, DWORD *len)
 
static BOOL send_request (struct request *request, const WCHAR *headers, DWORD headers_len, void *optional, DWORD optional_len, DWORD total_len, DWORD_PTR context, BOOL async)
 
static void task_send_request (struct task_header *task)
 
BOOL WINAPI WinHttpSendRequest (HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
 
static BOOL set_credentials (struct request *request, DWORD target, DWORD scheme_flag, const WCHAR *username, const WCHAR *password)
 
BOOL WINAPI WinHttpSetCredentials (HINTERNET hrequest, DWORD target, DWORD scheme, LPCWSTR username, LPCWSTR password, LPVOID params)
 
static BOOL handle_authorization (struct request *request, DWORD status)
 
static DWORD set_content_length (struct request *request, DWORD status)
 
static BOOL read_line (struct request *request, char *buffer, DWORD *len)
 
static void record_cookies (struct request *request)
 
static WCHARget_redirect_url (struct request *request, DWORD *len)
 
static BOOL handle_redirect (struct request *request, DWORD status)
 
static BOOL is_passport_request (struct request *request)
 
static BOOL handle_passport_redirect (struct request *request)
 
static BOOL receive_response (struct request *request, BOOL async)
 
static void task_receive_response (struct task_header *task)
 
BOOL WINAPI WinHttpReceiveResponse (HINTERNET hrequest, LPVOID reserved)
 
static BOOL query_data_available (struct request *request, DWORD *available, BOOL async)
 
static void task_query_data_available (struct task_header *task)
 
BOOL WINAPI WinHttpQueryDataAvailable (HINTERNET hrequest, LPDWORD available)
 
static void task_read_data (struct task_header *task)
 
BOOL WINAPI WinHttpReadData (HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
 
static BOOL write_data (struct request *request, const void *buffer, DWORD to_write, DWORD *written, BOOL async)
 
static void task_write_data (struct task_header *task)
 
BOOL WINAPI WinHttpWriteData (HINTERNET hrequest, LPCVOID buffer, DWORD to_write, LPDWORD written)
 
static struct winhttp_requestimpl_from_IWinHttpRequest (IWinHttpRequest *iface)
 
static ULONG WINAPI winhttp_request_AddRef (IWinHttpRequest *iface)
 
static void cancel_request (struct winhttp_request *request)
 
static void free_request (struct winhttp_request *request)
 
static ULONG WINAPI winhttp_request_Release (IWinHttpRequest *iface)
 
static HRESULT WINAPI winhttp_request_QueryInterface (IWinHttpRequest *iface, REFIID riid, void **obj)
 
static HRESULT WINAPI winhttp_request_GetTypeInfoCount (IWinHttpRequest *iface, UINT *count)
 
static HRESULT get_typeinfo (enum type_id tid, ITypeInfo **ret)
 
void release_typelib (void)
 
static HRESULT WINAPI winhttp_request_GetTypeInfo (IWinHttpRequest *iface, UINT index, LCID lcid, ITypeInfo **info)
 
static HRESULT WINAPI winhttp_request_GetIDsOfNames (IWinHttpRequest *iface, REFIID riid, LPOLESTR *names, UINT count, LCID lcid, DISPID *dispid)
 
static HRESULT WINAPI winhttp_request_Invoke (IWinHttpRequest *iface, DISPID member, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep_info, UINT *arg_err)
 
static HRESULT WINAPI winhttp_request_SetProxy (IWinHttpRequest *iface, HTTPREQUEST_PROXY_SETTING proxy_setting, VARIANT proxy_server, VARIANT bypass_list)
 
static HRESULT WINAPI winhttp_request_SetCredentials (IWinHttpRequest *iface, BSTR username, BSTR password, HTTPREQUEST_SETCREDENTIALS_FLAGS flags)
 
static void initialize_request (struct winhttp_request *request)
 
static void reset_request (struct winhttp_request *request)
 
static HRESULT WINAPI winhttp_request_Open (IWinHttpRequest *iface, BSTR method, BSTR url, VARIANT async)
 
static HRESULT WINAPI winhttp_request_SetRequestHeader (IWinHttpRequest *iface, BSTR header, BSTR value)
 
static HRESULT WINAPI winhttp_request_GetResponseHeader (IWinHttpRequest *iface, BSTR header, BSTR *value)
 
static HRESULT WINAPI winhttp_request_GetAllResponseHeaders (IWinHttpRequest *iface, BSTR *headers)
 
static void CALLBACK wait_status_callback (HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID buffer, DWORD size)
 
static void wait_set_status_callback (struct winhttp_request *request, DWORD status)
 
static DWORD wait_for_completion (struct winhttp_request *request)
 
static HRESULT request_receive (struct winhttp_request *request)
 
static DWORD request_set_parameters (struct winhttp_request *request)
 
static void request_set_utf8_content_type (struct winhttp_request *request)
 
static HRESULT request_send (struct winhttp_request *request)
 
static void CALLBACK send_and_receive_proc (TP_CALLBACK_INSTANCE *instance, void *ctx)
 
static DWORD request_wait (struct winhttp_request *request, DWORD timeout)
 
static HRESULT WINAPI winhttp_request_Send (IWinHttpRequest *iface, VARIANT body)
 
static HRESULT WINAPI winhttp_request_get_Status (IWinHttpRequest *iface, LONG *status)
 
static HRESULT WINAPI winhttp_request_get_StatusText (IWinHttpRequest *iface, BSTR *status)
 
static DWORD request_get_codepage (struct winhttp_request *request, UINT *codepage)
 
static HRESULT WINAPI winhttp_request_get_ResponseText (IWinHttpRequest *iface, BSTR *body)
 
static HRESULT WINAPI winhttp_request_get_ResponseBody (IWinHttpRequest *iface, VARIANT *body)
 
static struct streamimpl_from_IStream (IStream *iface)
 
static HRESULT WINAPI stream_QueryInterface (IStream *iface, REFIID riid, void **obj)
 
static ULONG WINAPI stream_AddRef (IStream *iface)
 
static ULONG WINAPI stream_Release (IStream *iface)
 
static HRESULT WINAPI stream_Read (IStream *iface, void *buf, ULONG len, ULONG *read)
 
static HRESULT WINAPI stream_Write (IStream *iface, const void *buf, ULONG len, ULONG *written)
 
static HRESULT WINAPI stream_Seek (IStream *iface, LARGE_INTEGER move, DWORD origin, ULARGE_INTEGER *newpos)
 
static HRESULT WINAPI stream_SetSize (IStream *iface, ULARGE_INTEGER newsize)
 
static HRESULT WINAPI stream_CopyTo (IStream *iface, IStream *stream, ULARGE_INTEGER len, ULARGE_INTEGER *read, ULARGE_INTEGER *written)
 
static HRESULT WINAPI stream_Commit (IStream *iface, DWORD flags)
 
static HRESULT WINAPI stream_Revert (IStream *iface)
 
static HRESULT WINAPI stream_LockRegion (IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER len, DWORD locktype)
 
static HRESULT WINAPI stream_UnlockRegion (IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER len, DWORD locktype)
 
static HRESULT WINAPI stream_Stat (IStream *iface, STATSTG *stg, DWORD flag)
 
static HRESULT WINAPI stream_Clone (IStream *iface, IStream **stream)
 
static HRESULT WINAPI winhttp_request_get_ResponseStream (IWinHttpRequest *iface, VARIANT *body)
 
static HRESULT WINAPI winhttp_request_get_Option (IWinHttpRequest *iface, WinHttpRequestOption option, VARIANT *value)
 
static HRESULT WINAPI winhttp_request_put_Option (IWinHttpRequest *iface, WinHttpRequestOption option, VARIANT value)
 
static HRESULT WINAPI winhttp_request_WaitForResponse (IWinHttpRequest *iface, VARIANT timeout, VARIANT_BOOL *succeeded)
 
static HRESULT WINAPI winhttp_request_Abort (IWinHttpRequest *iface)
 
static HRESULT WINAPI winhttp_request_SetTimeouts (IWinHttpRequest *iface, LONG resolve_timeout, LONG connect_timeout, LONG send_timeout, LONG receive_timeout)
 
static HRESULT WINAPI winhttp_request_SetClientCertificate (IWinHttpRequest *iface, BSTR certificate)
 
static HRESULT WINAPI winhttp_request_SetAutoLogonPolicy (IWinHttpRequest *iface, WinHttpRequestAutoLogonPolicy policy)
 
HRESULT WinHttpRequest_create (void **obj)
 

Variables

static const WCHAR attr_accept [] = {'A','c','c','e','p','t',0}
 
static const WCHAR attr_accept_charset [] = {'A','c','c','e','p','t','-','C','h','a','r','s','e','t', 0}
 
static const WCHAR attr_accept_encoding [] = {'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0}
 
static const WCHAR attr_accept_language [] = {'A','c','c','e','p','t','-','L','a','n','g','u','a','g','e',0}
 
static const WCHAR attr_accept_ranges [] = {'A','c','c','e','p','t','-','R','a','n','g','e','s',0}
 
static const WCHAR attr_age [] = {'A','g','e',0}
 
static const WCHAR attr_allow [] = {'A','l','l','o','w',0}
 
static const WCHAR attr_authorization [] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',0}
 
static const WCHAR attr_cache_control [] = {'C','a','c','h','e','-','C','o','n','t','r','o','l',0}
 
static const WCHAR attr_connection [] = {'C','o','n','n','e','c','t','i','o','n',0}
 
static const WCHAR attr_content_base [] = {'C','o','n','t','e','n','t','-','B','a','s','e',0}
 
static const WCHAR attr_content_encoding [] = {'C','o','n','t','e','n','t','-','E','n','c','o','d','i','n','g',0}
 
static const WCHAR attr_content_id [] = {'C','o','n','t','e','n','t','-','I','D',0}
 
static const WCHAR attr_content_language [] = {'C','o','n','t','e','n','t','-','L','a','n','g','u','a','g','e',0}
 
static const WCHAR attr_content_length [] = {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',0}
 
static const WCHAR attr_content_location [] = {'C','o','n','t','e','n','t','-','L','o','c','a','t','i','o','n',0}
 
static const WCHAR attr_content_md5 [] = {'C','o','n','t','e','n','t','-','M','D','5',0}
 
static const WCHAR attr_content_range [] = {'C','o','n','t','e','n','t','-','R','a','n','g','e',0}
 
static const WCHAR attr_content_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 attr_content_type [] = {'C','o','n','t','e','n','t','-','T','y','p','e',0}
 
static const WCHAR attr_cookie [] = {'C','o','o','k','i','e',0}
 
static const WCHAR attr_date [] = {'D','a','t','e',0}
 
static const WCHAR attr_from [] = {'F','r','o','m',0}
 
static const WCHAR attr_etag [] = {'E','T','a','g',0}
 
static const WCHAR attr_expect [] = {'E','x','p','e','c','t',0}
 
static const WCHAR attr_expires [] = {'E','x','p','i','r','e','s',0}
 
static const WCHAR attr_host [] = {'H','o','s','t',0}
 
static const WCHAR attr_if_match [] = {'I','f','-','M','a','t','c','h',0}
 
static const WCHAR attr_if_modified_since [] = {'I','f','-','M','o','d','i','f','i','e','d','-','S','i','n','c','e',0}
 
static const WCHAR attr_if_none_match [] = {'I','f','-','N','o','n','e','-','M','a','t','c','h',0}
 
static const WCHAR attr_if_range [] = {'I','f','-','R','a','n','g','e',0}
 
static const WCHAR attr_if_unmodified_since [] = {'I','f','-','U','n','m','o','d','i','f','i','e','d','-','S','i','n','c','e',0}
 
static const WCHAR attr_last_modified [] = {'L','a','s','t','-','M','o','d','i','f','i','e','d',0}
 
static const WCHAR attr_location [] = {'L','o','c','a','t','i','o','n',0}
 
static const WCHAR attr_max_forwards [] = {'M','a','x','-','F','o','r','w','a','r','d','s',0}
 
static const WCHAR attr_mime_version [] = {'M','i','m','e','-','V','e','r','s','i','o','n',0}
 
static const WCHAR attr_pragma [] = {'P','r','a','g','m','a',0}
 
static const WCHAR attr_proxy_authenticate [] = {'P','r','o','x','y','-','A','u','t','h','e','n','t','i','c','a','t','e',0}
 
static const WCHAR attr_proxy_authorization [] = {'P','r','o','x','y','-','A','u','t','h','o','r','i','z','a','t','i','o','n',0}
 
static const WCHAR attr_proxy_connection [] = {'P','r','o','x','y','-','C','o','n','n','e','c','t','i','o','n',0}
 
static const WCHAR attr_public [] = {'P','u','b','l','i','c',0}
 
static const WCHAR attr_range [] = {'R','a','n','g','e',0}
 
static const WCHAR attr_referer [] = {'R','e','f','e','r','e','r',0}
 
static const WCHAR attr_retry_after [] = {'R','e','t','r','y','-','A','f','t','e','r',0}
 
static const WCHAR attr_server [] = {'S','e','r','v','e','r',0}
 
static const WCHAR attr_set_cookie [] = {'S','e','t','-','C','o','o','k','i','e',0}
 
static const WCHAR attr_status [] = {'S','t','a','t','u','s',0}
 
static const WCHAR attr_transfer_encoding [] = {'T','r','a','n','s','f','e','r','-','E','n','c','o','d','i','n','g',0}
 
static const WCHAR attr_unless_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 attr_upgrade [] = {'U','p','g','r','a','d','e',0}
 
static const WCHAR attr_uri [] = {'U','R','I',0}
 
static const WCHAR attr_user_agent [] = {'U','s','e','r','-','A','g','e','n','t',0}
 
static const WCHAR attr_vary [] = {'V','a','r','y',0}
 
static const WCHAR attr_via [] = {'V','i','a',0}
 
static const WCHAR attr_warning [] = {'W','a','r','n','i','n','g',0}
 
static const WCHAR attr_www_authenticate [] = {'W','W','W','-','A','u','t','h','e','n','t','i','c','a','t','e',0}
 
static const WCHARattribute_table []
 
static const WCHAR basicW [] = {'B','a','s','i','c',0}
 
static const WCHAR ntlmW [] = {'N','T','L','M',0}
 
static const WCHAR passportW [] = {'P','a','s','s','p','o','r','t',0}
 
static const WCHAR digestW [] = {'D','i','g','e','s','t',0}
 
static const WCHAR negotiateW [] = {'N','e','g','o','t','i','a','t','e',0}
 
struct {
   const WCHAR *   str
 
   unsigned int   len
 
   DWORD   scheme
 
auth_schemes []
 
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 connection_collector_running
 
static ITypeLibwinhttp_typelib
 
static ITypeInfowinhttp_typeinfo [last_tid]
 
static REFIID winhttp_tid_id []
 
static const IStreamVtbl stream_vtbl
 
static const struct IWinHttpRequestVtbl winhttp_request_vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file request.c.

◆ DEFAULT_KEEP_ALIVE_TIMEOUT

#define DEFAULT_KEEP_ALIVE_TIMEOUT   30000

Definition at line 46 of file request.c.

◆ ESCAPE_MASK_DEFAULT

◆ ESCAPE_MASK_DISABLE

Definition at line 2096 of file request.c.

◆ ESCAPE_MASK_PERCENT

#define ESCAPE_MASK_PERCENT   (ESCAPE_FLAG_PERCENT | ESCAPE_MASK_DEFAULT)

Definition at line 2095 of file request.c.

◆ INITIAL_HEADER_BUFFER_LEN

#define INITIAL_HEADER_BUFFER_LEN   512

Definition at line 2569 of file request.c.

◆ MAX_REPLY_LEN

#define MAX_REPLY_LEN   1460

Definition at line 2568 of file request.c.

◆ QUERY_MODIFIER_MASK

Enumeration Type Documentation

◆ escape_flags

Enumerator
ESCAPE_FLAG_NON_PRINTABLE 
ESCAPE_FLAG_SPACE 
ESCAPE_FLAG_PERCENT 
ESCAPE_FLAG_UNSAFE 
ESCAPE_FLAG_DEL 
ESCAPE_FLAG_8BIT 
ESCAPE_FLAG_STRIP_CRLF 

Definition at line 2082 of file request.c.

◆ request_state

Enumerator
REQUEST_STATE_INITIALIZED 
REQUEST_STATE_CANCELLED 
REQUEST_STATE_OPEN 
REQUEST_STATE_SENT 
REQUEST_STATE_RESPONSE_RECEIVED 

Definition at line 3166 of file request.c.

◆ type_id

Enumerator
INetFwAuthorizedApplication_tid 
INetFwAuthorizedApplications_tid 
INetFwMgr_tid 
INetFwOpenPort_tid 
INetFwOpenPorts_tid 
INetFwPolicy_tid 
INetFwPolicy2_tid 
INetFwProfile_tid 
INetFwRules_tid 
IUPnPNAT_tid 
last_tid 
ISWbemLocator_tid 
ISWbemObject_tid 
ISWbemObjectSet_tid 
ISWbemProperty_tid 
ISWbemPropertySet_tid 
ISWbemServices_tid 
ISWbemSecurity_tid 
last_tid 
IWinHttpRequest_tid 
last_tid 

Definition at line 3329 of file request.c.

3330 {
3332  last_tid
3333 };

Function Documentation

◆ add_host_header()

static BOOL add_host_header ( struct request request,
DWORD  modifier 
)
static

Definition at line 1819 of file request.c.

1820 {
1821  BOOL ret;
1822  DWORD len;
1823  WCHAR *host;
1824  static const WCHAR fmt[] = {'%','s',':','%','u',0};
1825  struct connect *connect = request->connect;
1827 
1828  port = connect->hostport ? connect->hostport : (request->hdr.flags & WINHTTP_FLAG_SECURE ? 443 : 80);
1829 
1831  {
1832  return process_header( request, attr_host, connect->hostname, modifier, TRUE );
1833  }
1834  len = strlenW( connect->hostname ) + 7; /* sizeof(":65335") */
1835  if (!(host = heap_alloc( len * sizeof(WCHAR) ))) return FALSE;
1837  ret = process_header( request, attr_host, host, modifier, TRUE );
1838  heap_free( host );
1839  return ret;
1840 }
struct connect * connect
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
char * host
Definition: whois.c:55
BOOL process_header(struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only)
Definition: request.c:430
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define INTERNET_DEFAULT_HTTP_PORT
Definition: winhttp.h:36
WORD INTERNET_PORT
Definition: winhttp.h:38
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR * hostname
int ret
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR attr_host[]
Definition: request.c:74
#define INTERNET_DEFAULT_HTTPS_PORT
Definition: winhttp.h:37
INTERNET_PORT hostport
#define sprintfW
Definition: unicode.h:58
struct object_header hdr
Definition: tftpd.h:85
unsigned int len
Definition: request.c:891
USHORT port
Definition: uri.c:228
Definition: dsound.c:943
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by handle_redirect(), and send_request().

◆ add_request_headers()

BOOL add_request_headers ( struct request request,
const WCHAR headers,
DWORD  len,
DWORD  flags 
)

Definition at line 495 of file request.c.

496 {
497  BOOL ret = FALSE;
498  WCHAR *buffer, *p, *q;
499  struct header *header;
500 
501  if (len == ~0u) len = strlenW( headers );
502  if (!len) return TRUE;
503  if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
504  memcpy( buffer, headers, len * sizeof(WCHAR) );
505  buffer[len] = 0;
506 
507  p = buffer;
508  do
509  {
510  q = p;
511  while (*q)
512  {
513  if (q[0] == '\n' && q[1] == '\r')
514  {
515  q[0] = '\r';
516  q[1] = '\n';
517  }
518  if (q[0] == '\r' && q[1] == '\n') break;
519  q++;
520  }
521  if (!*p) break;
522  if (*q == '\r')
523  {
524  *q = 0;
525  q += 2; /* jump over \r\n */
526  }
527  if ((header = parse_header( p )))
528  {
530  free_header( header );
531  }
532  p = q;
533  } while (ret);
534 
535  heap_free( buffer );
536  return ret;
537 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
WCHAR * field
GLuint buffer
Definition: glext.h:5915
BOOL process_header(struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only)
Definition: request.c:430
vector< Header * > headers
Definition: sdkparse.cpp:39
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
WCHAR * value
__wchar_t WCHAR
Definition: xmlstorage.h:180
static struct header * parse_header(const WCHAR *string)
Definition: request.c:325
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLbitfield flags
Definition: glext.h:7161
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
Definition: tftpd.h:85
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int len
Definition: request.c:891
struct CFHEADER header
Definition: fdi.c:101
static void free_header(struct header *header)
Definition: request.c:297
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by add_cookie_headers(), send_request(), and WinHttpAddRequestHeaders().

◆ addr_to_str()

static WCHAR* addr_to_str ( struct sockaddr_storage addr)
static

Definition at line 1462 of file request.c.

1463 {
1464  char buf[INET6_ADDRSTRLEN];
1465  void *src;
1466 
1467  switch (addr->ss_family)
1468  {
1469  case AF_INET:
1470  src = &((struct sockaddr_in *)addr)->sin_addr;
1471  break;
1472  case AF_INET6:
1473  src = &((struct sockaddr_in6 *)addr)->sin6_addr;
1474  break;
1475  default:
1476  WARN("unsupported address family %d\n", addr->ss_family);
1477  return NULL;
1478  }
1479  if (!inet_ntop( addr->ss_family, src, buf, sizeof(buf) )) return NULL;
1480  return strdupAW( buf );
1481 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WARN(fmt,...)
Definition: debug.h:111
static WCHAR * strdupAW(const char *src, int len)
Definition: main.c:76
smooth NULL
Definition: ftsmooth.c:416
#define AF_INET6
Definition: winsock.h:369
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum src
Definition: glext.h:6340
#define INET6_ADDRSTRLEN
Definition: ws2ipdef.h:132
#define AF_INET
Definition: tcpip.h:117
const char *WSAAPI inet_ntop(int af, const void *src, char *dst, size_t cnt)
Definition: unix_func.c:8

Referenced by open_connection().

◆ alloc_authinfo()

static struct authinfo* alloc_authinfo ( void  )
static

Definition at line 1120 of file request.c.

1121 {
1122  struct authinfo *ret;
1123 
1124  if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
1125 
1126  SecInvalidateHandle( &ret->cred );
1127  SecInvalidateHandle( &ret->ctx );
1128  memset( &ret->exp, 0, sizeof(ret->exp) );
1129  ret->scheme = 0;
1130  ret->attr = 0;
1131  ret->max_token = 0;
1132  ret->data = NULL;
1133  ret->data_len = 0;
1134  ret->finished = FALSE;
1135  return ret;
1136 }
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define SecInvalidateHandle(x)
Definition: sspi.h:58
smooth NULL
Definition: ftsmooth.c:416
int ret
#define memset(x, y, z)
Definition: compat.h:39

Referenced by do_authorization().

◆ auth_scheme_from_header()

static DWORD auth_scheme_from_header ( const WCHAR header)
static

Definition at line 911 of file request.c.

912 {
913  unsigned int i;
914 
915  for (i = 0; i < ARRAY_SIZE( auth_schemes ); i++)
916  {
918  (header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
919  }
920  return 0;
921 }
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
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
const WCHAR * str
Definition: request.c:890
GLenum GLsizei len
Definition: glext.h:6722
#define ARRAY_SIZE(a)
Definition: main.h:24
static const struct @579 auth_schemes[]

Referenced by get_authvalue(), and query_auth_schemes().

◆ build_absolute_request_path()

static WCHAR* build_absolute_request_path ( struct request request,
const WCHAR **  path 
)
static

Definition at line 573 of file request.c.

574 {
575  static const WCHAR http[] = {'h','t','t','p',0};
576  static const WCHAR https[] = {'h','t','t','p','s',0};
577  static const WCHAR fmt[] = {'%','s',':','/','/','%','s',0};
578  const WCHAR *scheme;
579  WCHAR *ret;
580  int len;
581 
582  scheme = (request->netconn ? request->netconn->secure : (request->hdr.flags & WINHTTP_FLAG_SECURE)) ? https : http;
583 
584  len = strlenW( scheme ) + strlenW( request->connect->hostname ) + 4; /* '://' + nul */
585  if (request->connect->hostport) len += 6; /* ':' between host and port, up to 5 for port */
586 
587  len += strlenW( request->path );
588  if ((ret = heap_alloc( len * sizeof(WCHAR) )))
589  {
590  len = sprintfW( ret, fmt, scheme, request->connect->hostname );
591  if (request->connect->hostport)
592  {
593  static const WCHAR port_fmt[] = {':','%','u',0};
594  len += sprintfW( ret + len, port_fmt, request->connect->hostport );
595  }
596  strcpyW( ret + len, request->path );
597  if (path) *path = ret + len;
598  }
599 
600  return ret;
601 }
struct connect * connect
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
char path[256]
Definition: tftpd.h:94
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
GLenum GLsizei len
Definition: glext.h:6722
static WCHAR http[]
Definition: url.c:30
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define sprintfW
Definition: unicode.h:58
struct object_header hdr
struct netconn * netconn
DWORD scheme
Definition: request.c:892
Definition: tftpd.h:85
unsigned int len
Definition: request.c:891
Definition: dsound.c:943

Referenced by build_request_string(), and build_wire_path().

◆ build_proxy_connect_string()

static WCHAR* build_proxy_connect_string ( struct request request)
static

Definition at line 1392 of file request.c.

1393 {
1394  static const WCHAR fmtW[] = {'%','s',':','%','u',0};
1395  static const WCHAR connectW[] = {'C','O','N','N','E','C','T', 0};
1396  static const WCHAR spaceW[] = {' ',0}, crlfW[] = {'\r','\n',0}, colonW[] = {':',' ',0};
1397  static const WCHAR twocrlfW[] = {'\r','\n','\r','\n',0};
1398  WCHAR *ret, *host;
1399  unsigned int i;
1400  int len;
1401 
1402  if (!(host = heap_alloc( (strlenW( request->connect->hostname ) + 7) * sizeof(WCHAR) ))) return NULL;
1403  len = sprintfW( host, fmtW, request->connect->hostname, request->connect->hostport );
1404 
1405  len += ARRAY_SIZE(connectW);
1406  len += ARRAY_SIZE(http1_1);
1407 
1408  for (i = 0; i < request->num_headers; i++)
1409  {
1410  if (request->headers[i].is_request)
1411  len += strlenW( request->headers[i].field ) + strlenW( request->headers[i].value ) + 4; /* '\r\n: ' */
1412  }
1413  len += 4; /* '\r\n\r\n' */
1414 
1415  if ((ret = heap_alloc( (len + 1) * sizeof(WCHAR) )))
1416  {
1417  strcpyW( ret, connectW );
1418  strcatW( ret, spaceW );
1419  strcatW( ret, host );
1420  strcatW( ret, spaceW );
1421  strcatW( ret, http1_1 );
1422 
1423  for (i = 0; i < request->num_headers; i++)
1424  {
1425  if (request->headers[i].is_request)
1426  {
1427  strcatW( ret, crlfW );
1428  strcatW( ret, request->headers[i].field );
1429  strcatW( ret, colonW );
1430  strcatW( ret, request->headers[i].value );
1431  }
1432  }
1433  strcatW( ret, twocrlfW );
1434  }
1435 
1436  heap_free( host );
1437  return ret;
1438 }
struct connect * connect
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
char * host
Definition: whois.c:55
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static const WCHAR crlfW[]
Definition: mxwriter.c:47
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
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
struct header * headers
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR spaceW[]
Definition: mxwriter.c:44
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define ARRAY_SIZE(a)
Definition: main.h:24
#define sprintfW
Definition: unicode.h:58
static const WCHAR http1_1[]
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
Definition: tftpd.h:85
DWORD num_headers
unsigned int len
Definition: request.c:891
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by secure_proxy_connect().

◆ build_request_string()

static WCHAR* build_request_string ( struct request request)
static

Definition at line 603 of file request.c.

604 {
605  static const WCHAR spaceW[] = {' ',0}, crlfW[] = {'\r','\n',0}, colonW[] = {':',' ',0};
606  static const WCHAR twocrlfW[] = {'\r','\n','\r','\n',0};
607  WCHAR *path, *ret;
608  unsigned int i, len;
609 
610  if (!strcmpiW( request->connect->hostname, request->connect->servername )) path = request->path;
611  else if (!(path = build_absolute_request_path( request, NULL ))) return NULL;
612 
613  len = strlenW( request->verb ) + 1 /* ' ' */;
614  len += strlenW( path ) + 1 /* ' ' */;
615  len += strlenW( request->version );
616 
617  for (i = 0; i < request->num_headers; i++)
618  {
619  if (request->headers[i].is_request)
620  len += strlenW( request->headers[i].field ) + strlenW( request->headers[i].value ) + 4; /* '\r\n: ' */
621  }
622  len += 4; /* '\r\n\r\n' */
623 
624  if ((ret = heap_alloc( (len + 1) * sizeof(WCHAR) )))
625  {
626  strcpyW( ret, request->verb );
627  strcatW( ret, spaceW );
628  strcatW( ret, path );
629  strcatW( ret, spaceW );
630  strcatW( ret, request->version );
631 
632  for (i = 0; i < request->num_headers; i++)
633  {
634  if (request->headers[i].is_request)
635  {
636  strcatW( ret, crlfW );
637  strcatW( ret, request->headers[i].field );
638  strcatW( ret, colonW );
639  strcatW( ret, request->headers[i].value );
640  }
641  }
642  strcatW( ret, twocrlfW );
643  }
644 
645  if (path != request->path) heap_free( path );
646  return ret;
647 }
struct connect * connect
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLsizei const GLchar ** path
Definition: glext.h:7234
WCHAR * version
static WCHAR * build_absolute_request_path(struct request *request, const WCHAR **path)
Definition: request.c:573
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static const WCHAR crlfW[]
Definition: mxwriter.c:47
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
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
struct header * headers
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR spaceW[]
Definition: mxwriter.c:44
WCHAR * verb
#define strcmpiW(s1, s2)
Definition: unicode.h:39
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
DWORD num_headers
unsigned int len
Definition: request.c:891
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by query_headers().

◆ build_wire_path()

static char* build_wire_path ( struct request request,
DWORD ret_len 
)
static

Definition at line 2159 of file request.c.

2160 {
2161  WCHAR *full_path;
2162  const WCHAR *start, *path, *query = NULL;
2163  DWORD len, len_path = 0, len_query = 0;
2164  enum escape_flags path_flags, query_flags;
2165  char *ret;
2166 
2167  if (!strcmpiW( request->connect->hostname, request->connect->servername )) start = full_path = request->path;
2168  else if (!(full_path = build_absolute_request_path( request, &start ))) return NULL;
2169 
2170  len = strlenW( full_path );
2171  if ((path = strchrW( start, '/' )))
2172  {
2173  len_path = strlenW( path );
2174  if ((query = strchrW( path, '?' )))
2175  {
2176  len_query = strlenW( query );
2177  len_path -= len_query;
2178  }
2179  }
2180 
2181  if (request->hdr.flags & WINHTTP_FLAG_ESCAPE_DISABLE) path_flags = ESCAPE_MASK_DISABLE;
2182  else if (request->hdr.flags & WINHTTP_FLAG_ESCAPE_PERCENT) path_flags = ESCAPE_MASK_PERCENT;
2183  else path_flags = ESCAPE_MASK_DEFAULT;
2184 
2186  else query_flags = path_flags;
2187 
2188  *ret_len = str_to_wire( full_path, len - len_path - len_query, NULL, 0 );
2189  if (path) *ret_len += str_to_wire( path, len_path, NULL, path_flags );
2190  if (query) *ret_len += str_to_wire( query, len_query, NULL, query_flags );
2191 
2192  if ((ret = heap_alloc( *ret_len + 1 )))
2193  {
2194  len = str_to_wire( full_path, len - len_path - len_query, ret, 0 );
2195  if (path) len += str_to_wire( path, len_path, ret + len, path_flags );
2196  if (query) str_to_wire( query, len_query, ret + len, query_flags );
2197  }
2198 
2199  if (full_path != request->path) heap_free( full_path );
2200  return ret;
2201 }
struct connect * connect
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLsizei const GLchar ** path
Definition: glext.h:7234
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
static WCHAR * build_absolute_request_path(struct request *request, const WCHAR **path)
Definition: request.c:573
static DWORD str_to_wire(const WCHAR *src, int src_len, char *dst, enum escape_flags flags)
Definition: request.c:2143
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
#define ESCAPE_MASK_DEFAULT
Definition: request.c:2093
#define WINHTTP_FLAG_ESCAPE_DISABLE
Definition: winhttp.h:56
#define ESCAPE_MASK_PERCENT
Definition: request.c:2095
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static JOBOBJECTINFOCLASS LPVOID DWORD LPDWORD ret_len
Definition: process.c:79
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define WINHTTP_FLAG_ESCAPE_PERCENT
Definition: winhttp.h:54
#define strcmpiW(s1, s2)
Definition: unicode.h:39
GLuint start
Definition: gl.h:1545
struct object_header hdr
Definition: tftpd.h:85
#define WINHTTP_FLAG_ESCAPE_DISABLE_QUERY
Definition: winhttp.h:57
unsigned int len
Definition: request.c:891
#define ESCAPE_MASK_DISABLE
Definition: request.c:2096
escape_flags
Definition: request.c:2082
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by build_wire_request().

◆ build_wire_request()

static char* build_wire_request ( struct request request,
DWORD len 
)
static

Definition at line 2203 of file request.c.

2204 {
2205  char *path, *ptr, *ret;
2206  DWORD i, len_path;
2207 
2208  if (!(path = build_wire_path( request, &len_path ))) return NULL;
2209 
2210  *len = str_to_wire( request->verb, -1, NULL, 0 ) + 1; /* ' ' */
2211  *len += len_path + 1; /* ' ' */
2212  *len += str_to_wire( request->version, -1, NULL, 0 );
2213 
2214  for (i = 0; i < request->num_headers; i++)
2215  {
2216  if (request->headers[i].is_request)
2217  {
2218  *len += str_to_wire( request->headers[i].field, -1, NULL, 0 ) + 2; /* ': ' */
2219  *len += str_to_wire( request->headers[i].value, -1, NULL, 0 ) + 2; /* '\r\n' */
2220  }
2221  }
2222  *len += 4; /* '\r\n\r\n' */
2223 
2224  if ((ret = ptr = heap_alloc( *len + 1 )))
2225  {
2226  ptr += str_to_wire( request->verb, -1, ptr, 0 );
2227  *ptr++ = ' ';
2228  memcpy( ptr, path, len_path );
2229  ptr += len_path;
2230  *ptr++ = ' ';
2231  ptr += str_to_wire( request->version, -1, ptr, 0 );
2232 
2233  for (i = 0; i < request->num_headers; i++)
2234  {
2235  if (request->headers[i].is_request)
2236  {
2237  *ptr++ = '\r';
2238  *ptr++ = '\n';
2239  ptr += str_to_wire( request->headers[i].field, -1, ptr, 0 );
2240  *ptr++ = ':';
2241  *ptr++ = ' ';
2242  ptr += str_to_wire( request->headers[i].value, -1, ptr, 0 );
2243  }
2244  }
2245  memcpy( ptr, "\r\n\r\n", sizeof("\r\n\r\n") );
2246  }
2247 
2248  heap_free( path );
2249  return ret;
2250 }
GLsizei const GLchar ** path
Definition: glext.h:7234
WCHAR * version
static char * build_wire_path(struct request *request, DWORD *ret_len)
Definition: request.c:2159
static DWORD str_to_wire(const WCHAR *src, int src_len, char *dst, enum escape_flags flags)
Definition: request.c:2143
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
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
struct header * headers
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
WCHAR * verb
Definition: tftpd.h:85
DWORD num_headers
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by send_request().

◆ cache_connection()

static void cache_connection ( struct netconn netconn)
static

Definition at line 1556 of file request.c.

1557 {
1558  TRACE( "caching connection %p\n", netconn );
1559 
1561 
1563  list_add_head( &netconn->host->connections, &netconn->entry );
1564 
1566  {
1567  HMODULE module;
1568 #ifdef __REACTOS__
1569  HANDLE thread;
1570 #endif
1571 
1572  GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const WCHAR *)winhttp_instance, &module );
1573 
1574 #ifdef __REACTOS__
1576  if (thread)
1577  {
1578  CloseHandle( thread );
1580  }
1581  else
1582  {
1584  }
1585 #else
1586  if (TrySubmitThreadpoolCallback( connection_collector, NULL, NULL )) connection_collector_running = TRUE;
1587  else FreeLibrary( winhttp_instance );
1588 #endif
1589  }
1590 
1592 }
ULONGLONG keep_until
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
HMODULE module
Definition: main.cpp:47
static void CALLBACK connection_collector(TP_CALLBACK_INSTANCE *instance, void *ctx)
Definition: request.c:1513
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
struct list entry
static CRITICAL_SECTION connection_pool_cs
Definition: request.c:1483
#define DEFAULT_KEEP_ALIVE_TIMEOUT
Definition: request.c:46
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:413
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HANDLE thread
Definition: service.c:33
struct hostdata * host
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:875
static BOOL connection_collector_running
Definition: request.c:1508
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
HINSTANCE winhttp_instance
Definition: main.c:34

Referenced by finished_reading().

◆ cancel_request()

static void cancel_request ( struct winhttp_request request)
static

Definition at line 3225 of file request.c.

3226 {
3227  if (request->state <= REQUEST_STATE_CANCELLED) return;
3228 
3229 #ifdef __REACTOS__
3230  SetEvent( request->cancel );
3231  LeaveCriticalSection( &request->cs );
3232  WaitForSingleObject( request->thread, INFINITE );
3233  EnterCriticalSection( &request->cs );
3234 
3236 
3237  CloseHandle( request->thread );
3238  request->thread = NULL;
3239 #else
3240  if (request->proc_running)
3241  {
3242  SetEvent( request->cancel );
3243  LeaveCriticalSection( &request->cs );
3244 
3246 
3247  EnterCriticalSection( &request->cs );
3248  }
3250 #endif
3251 }
#define CloseHandle
Definition: compat.h:406
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
Definition: tftpd.h:85
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define INFINITE
Definition: serial.h:102

Referenced by reset_request(), winhttp_request_Abort(), and winhttp_request_Release().

◆ clear_response_headers()

static void clear_response_headers ( struct request request)
static

Definition at line 1842 of file request.c.

1843 {
1844  unsigned int i;
1845 
1846  for (i = 0; i < request->num_headers; i++)
1847  {
1848  if (!request->headers[i].field) continue;
1849  if (!request->headers[i].value) continue;
1850  if (request->headers[i].is_request) continue;
1851  delete_header( request, i );
1852  i--;
1853  }
1854 }
static BOOL delete_header(struct request *request, DWORD index)
Definition: request.c:415
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
struct header * headers
Definition: tftpd.h:85
DWORD num_headers

Referenced by send_request().

◆ close_connection()

void close_connection ( struct request request)

Definition at line 1809 of file request.c.

1810 {
1811  if (!request->netconn) return;
1812 
1815  request->netconn = NULL;
1817 }
#define WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION
Definition: winhttp.h:388
smooth NULL
Definition: ftsmooth.c:416
void netconn_close(struct netconn *conn)
Definition: net.c:244
void send_callback(struct object_header *hdr, DWORD status, void *info, DWORD buflen)
Definition: session.c:55
struct object_header hdr
struct netconn * netconn
Definition: tftpd.h:85
#define WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED
Definition: winhttp.h:389

Referenced by finished_reading(), and release_object().

◆ connection_collector()

static void CALLBACK connection_collector ( TP_CALLBACK_INSTANCE instance,
void ctx 
)
static

Definition at line 1513 of file request.c.

1515 {
1516  unsigned int remaining_connections;
1517  struct netconn *netconn, *next_netconn;
1518  struct hostdata *host, *next_host;
1519  ULONGLONG now;
1520 
1521  do
1522  {
1523  /* FIXME: Use more sophisticated method */
1524  Sleep(5000);
1525  remaining_connections = 0;
1526  now = GetTickCount64();
1527 
1529 
1531  {
1532  LIST_FOR_EACH_ENTRY_SAFE(netconn, next_netconn, &host->connections, struct netconn, entry)
1533  {
1534  if (netconn->keep_until < now)
1535  {
1536  TRACE("freeing %p\n", netconn);
1539  }
1540  else remaining_connections++;
1541  }
1542  }
1543 
1544  if (!remaining_connections) connection_collector_running = FALSE;
1545 
1547  } while(remaining_connections);
1548 
1549 #ifdef __REACTOS__
1551 #else
1552  FreeLibraryWhenCallbackReturns( instance, winhttp_instance );
1553 #endif
1554 }
ULONGLONG keep_until
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
char * host
Definition: whois.c:55
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
struct list entry
static CRITICAL_SECTION connection_pool_cs
Definition: request.c:1483
VOID WINAPI FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode)
Definition: loader.c:516
static struct list connection_pool
Definition: request.c:1492
time_t now
Definition: finger.c:65
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
uint64_t ULONGLONG
Definition: typedefs.h:65
uint32_t entry
Definition: isohybrid.c:63
void netconn_close(struct netconn *conn)
Definition: net.c:244
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
static HINSTANCE instance
Definition: main.c:40
static BOOL connection_collector_running
Definition: request.c:1508
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
HINSTANCE winhttp_instance
Definition: main.c:34

Referenced by cache_connection().

◆ decode_base64()

static unsigned int decode_base64 ( const WCHAR base64,
unsigned int  len,
char buf 
)
static

Definition at line 1058 of file request.c.

1059 {
1060  unsigned int i = 0;
1061  char c0, c1, c2, c3;
1062  const WCHAR *p = base64;
1063 
1064  while (len > 4)
1065  {
1066  if ((c0 = decode_char( p[0] )) > 63) return 0;
1067  if ((c1 = decode_char( p[1] )) > 63) return 0;
1068  if ((c2 = decode_char( p[2] )) > 63) return 0;
1069  if ((c3 = decode_char( p[3] )) > 63) return 0;
1070 
1071  if (buf)
1072  {
1073  buf[i + 0] = (c0 << 2) | (c1 >> 4);
1074  buf[i + 1] = (c1 << 4) | (c2 >> 2);
1075  buf[i + 2] = (c2 << 6) | c3;
1076  }
1077  len -= 4;
1078  i += 3;
1079  p += 4;
1080  }
1081  if (p[2] == '=')
1082  {
1083  if ((c0 = decode_char( p[0] )) > 63) return 0;
1084  if ((c1 = decode_char( p[1] )) > 63) return 0;
1085 
1086  if (buf) buf[i] = (c0 << 2) | (c1 >> 4);
1087  i++;
1088  }
1089  else if (p[3] == '=')
1090  {
1091  if ((c0 = decode_char( p[0] )) > 63) return 0;
1092  if ((c1 = decode_char( p[1] )) > 63) return 0;
1093  if ((c2 = decode_char( p[2] )) > 63) return 0;
1094 
1095  if (buf)
1096  {
1097  buf[i + 0] = (c0 << 2) | (c1 >> 4);
1098  buf[i + 1] = (c1 << 4) | (c2 >> 2);
1099  }
1100  i += 2;
1101  }
1102  else
1103  {
1104  if ((c0 = decode_char( p[0] )) > 63) return 0;
1105  if ((c1 = decode_char( p[1] )) > 63) return 0;
1106  if ((c2 = decode_char( p[2] )) > 63) return 0;
1107  if ((c3 = decode_char( p[3] )) > 63) return 0;
1108 
1109  if (buf)
1110  {
1111  buf[i + 0] = (c0 << 2) | (c1 >> 4);
1112  buf[i + 1] = (c1 << 4) | (c2 >> 2);
1113  buf[i + 2] = (c2 << 6) | c3;
1114  }
1115  i += 3;
1116  }
1117  return i;
1118 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static char decode_char(WCHAR c)
Definition: request.c:1048
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by do_authorization().

◆ decode_char()

static char decode_char ( WCHAR  c)
inlinestatic

Definition at line 1048 of file request.c.

1049 {
1050  if (c >= 'A' && c <= 'Z') return c - 'A';
1051  if (c >= 'a' && c <= 'z') return c - 'a' + 26;
1052  if (c >= '0' && c <= '9') return c - '0' + 52;
1053  if (c == '+') return 62;
1054  if (c == '/') return 63;
1055  return 64;
1056 }
const GLubyte * c
Definition: glext.h:8905

Referenced by decode_base64().

◆ delete_header()

static BOOL delete_header ( struct request request,
DWORD  index 
)
static

Definition at line 415 of file request.c.

416 {
417  if (!request->num_headers) return FALSE;
418  if (index >= request->num_headers) return FALSE;
419  request->num_headers--;
420 
421  heap_free( request->headers[index].field );
422  heap_free( request->headers[index].value );
423 
425  (request->num_headers - index) * sizeof(struct header) );
426  memset( &request->headers[request->num_headers], 0, sizeof(struct header) );
427  return TRUE;
428 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
GLuint index
Definition: glext.h:6031
struct header * headers
Definition: tftpd.h:85
DWORD num_headers
#define memset(x, y, z)
Definition: compat.h:39
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by clear_response_headers(), handle_redirect(), and process_header().

◆ dequeue_task()

static struct task_header* dequeue_task ( struct request request)
static

Definition at line 184 of file request.c.

185 {
186  struct task_header *task;
187 
189  TRACE("%u tasks queued\n", list_count( &request->task_queue ));
190  task = LIST_ENTRY( list_head( &request->task_queue ), struct task_header, entry );
191  if (task) list_remove( &task->entry );
193 
194  TRACE("returning task %p\n", task);
195  return task;
196 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
Definition: list.h:155
struct list task_queue
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
struct list entry
uint32_t entry
Definition: isohybrid.c:63
CRITICAL_SECTION task_cs
Definition: tftpd.h:85
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by task_proc().

◆ destroy_authinfo()

void destroy_authinfo ( struct authinfo authinfo)

Definition at line 1138 of file request.c.

1139 {
1140  if (!authinfo) return;
1141 
1142  if (SecIsValidHandle( &authinfo->ctx ))
1144  if (SecIsValidHandle( &authinfo->cred ))
1146 
1147  heap_free( authinfo->data );
1148  heap_free( authinfo );
1149 }
#define SecIsValidHandle(x)
Definition: sspi.h:63
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
CredHandle cred
char * data
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
CtxtHandle ctx

Referenced by do_authorization().

◆ discard_eol()

static BOOL discard_eol ( struct request request,
BOOL  notify 
)
static

Definition at line 1891 of file request.c.

1892 {
1893  do
1894  {
1895  char *eol = memchr( request->read_buf + request->read_pos, '\n', request->read_size );
1896  if (eol)
1897  {
1898  remove_data( request, (eol + 1) - (request->read_buf + request->read_pos) );
1899  break;
1900  }
1901  request->read_pos = request->read_size = 0; /* discard everything */
1902  if (!read_more_data( request, -1, notify )) return FALSE;
1903  } while (request->read_size);
1904  return TRUE;
1905 }
#define TRUE
Definition: types.h:120
#define memchr(s, c, n)
Definition: mkisofs.h:875
int notify
Definition: msacm.c:1365
char read_buf[8192]
DWORD read_pos
static void remove_data(struct request *request, int count)
Definition: request.c:1857
DWORD read_size
Definition: tftpd.h:85
static BOOL read_more_data(struct request *request, int maxlen, BOOL notify)
Definition: request.c:1864

Referenced by start_next_chunk().

◆ do_authorization()

static BOOL do_authorization ( struct request request,
DWORD  target,
DWORD  scheme_flag 
)
static

Definition at line 1163 of file request.c.

1164 {
1165  struct authinfo *authinfo, **auth_ptr;
1166  enum auth_scheme scheme = scheme_from_flag( scheme_flag );
1167  const WCHAR *auth_target, *username, *password;
1168  WCHAR auth_value[2048], *auth_reply;
1169  DWORD len = sizeof(auth_value), len_scheme, flags;
1170  BOOL ret, has_auth_value;
1171 
1172  if (scheme == SCHEME_INVALID) return FALSE;
1173 
1174  switch (target)
1175  {
1177  has_auth_value = get_authvalue( request, WINHTTP_QUERY_WWW_AUTHENTICATE, scheme_flag, auth_value, len );
1178  auth_ptr = &request->authinfo;
1180  if (request->creds[TARGET_SERVER][scheme].username)
1181  {
1182  if (scheme != SCHEME_BASIC && !has_auth_value) return FALSE;
1183  username = request->creds[TARGET_SERVER][scheme].username;
1184  password = request->creds[TARGET_SERVER][scheme].password;
1185  }
1186  else
1187  {
1188  if (!has_auth_value) return FALSE;
1189  username = request->connect->username;
1190  password = request->connect->password;
1191  }
1192  break;
1193 
1195  if (!get_authvalue( request, WINHTTP_QUERY_PROXY_AUTHENTICATE, scheme_flag, auth_value, len ))
1196  return FALSE;
1197  auth_ptr = &request->proxy_authinfo;
1199  if (request->creds[TARGET_PROXY][scheme].username)
1200  {
1201  username = request->creds[TARGET_PROXY][scheme].username;
1202  password = request->creds[TARGET_PROXY][scheme].password;
1203  }
1204  else
1205  {
1206  username = request->connect->session->proxy_username;
1207  password = request->connect->session->proxy_password;
1208  }
1209  break;
1210 
1211  default:
1212  WARN("unknown target %x\n", target);
1213  return FALSE;
1214  }
1215  authinfo = *auth_ptr;
1216 
1217  switch (scheme)
1218  {
1219  case SCHEME_BASIC:
1220  {
1221  int userlen, passlen;
1222 
1223  if (!username || !password) return FALSE;
1224  if ((!authinfo && !(authinfo = alloc_authinfo())) || authinfo->finished) return FALSE;
1225 
1226  userlen = WideCharToMultiByte( CP_UTF8, 0, username, strlenW( username ), NULL, 0, NULL, NULL );
1227  passlen = WideCharToMultiByte( CP_UTF8, 0, password, strlenW( password ), NULL, 0, NULL, NULL );
1228 
1229  authinfo->data_len = userlen + 1 + passlen;
1230  if (!(authinfo->data = heap_alloc( authinfo->data_len ))) return FALSE;
1231 
1232  WideCharToMultiByte( CP_UTF8, 0, username, -1, authinfo->data, userlen, NULL, NULL );
1233  authinfo->data[userlen] = ':';
1234  WideCharToMultiByte( CP_UTF8, 0, password, -1, authinfo->data + userlen + 1, passlen, NULL, NULL );
1235 
1237  authinfo->finished = TRUE;
1238  break;
1239  }
1240  case SCHEME_NTLM:
1241  case SCHEME_NEGOTIATE:
1242  {
1244  SecBufferDesc out_desc, in_desc;
1245  SecBuffer out, in;
1247  const WCHAR *p;
1248  BOOL first = FALSE;
1249 
1250  if (!authinfo)
1251  {
1252  TimeStamp exp;
1254  WCHAR *domain, *user;
1255 
1256  if (!username || !password || !(authinfo = alloc_authinfo())) return FALSE;
1257 
1258  first = TRUE;
1259  domain = (WCHAR *)username;
1260  user = strchrW( username, '\\' );
1261 
1262  if (user) user++;
1263  else
1264  {
1265  user = (WCHAR *)username;
1266  domain = NULL;
1267  }
1269  id.User = user;
1270  id.UserLength = strlenW( user );
1271  id.Domain = domain;
1272  id.DomainLength = domain ? user - domain - 1 : 0;
1273  id.Password = (WCHAR *)password;
1274  id.PasswordLength = strlenW( password );
1275 
1278  &authinfo->cred, &exp );
1279  if (status == SEC_E_OK)
1280  {
1283  if (status == SEC_E_OK)
1284  {
1285  authinfo->max_token = info->cbMaxToken;
1287  }
1288  }
1289  if (status != SEC_E_OK)
1290  {
1291  WARN("AcquireCredentialsHandleW for scheme %s failed with error 0x%08x\n",
1293  heap_free( authinfo );
1294  return FALSE;
1295  }
1296  authinfo->scheme = scheme;
1297  }
1298  else if (authinfo->finished) return FALSE;
1299 
1300  if ((strlenW( auth_value ) < auth_schemes[authinfo->scheme].len ||
1301  strncmpiW( auth_value, auth_schemes[authinfo->scheme].str, auth_schemes[authinfo->scheme].len )))
1302  {
1303  ERR("authentication scheme changed from %s to %s\n",
1304  debugstr_w(auth_schemes[authinfo->scheme].str), debugstr_w(auth_value));
1306  *auth_ptr = NULL;
1307  return FALSE;
1308  }
1309  in.BufferType = SECBUFFER_TOKEN;
1310  in.cbBuffer = 0;
1311  in.pvBuffer = NULL;
1312 
1313  in_desc.ulVersion = 0;
1314  in_desc.cBuffers = 1;
1315  in_desc.pBuffers = &in;
1316 
1317  p = auth_value + auth_schemes[scheme].len;
1318  if (*p == ' ')
1319  {
1320  int len = strlenW( ++p );
1321  in.cbBuffer = decode_base64( p, len, NULL );
1322  if (!(in.pvBuffer = heap_alloc( in.cbBuffer ))) {
1324  *auth_ptr = NULL;
1325  return FALSE;
1326  }
1327  decode_base64( p, len, in.pvBuffer );
1328  }
1329  out.BufferType = SECBUFFER_TOKEN;
1330  out.cbBuffer = authinfo->max_token;
1331  if (!(out.pvBuffer = heap_alloc( authinfo->max_token )))
1332  {
1333  heap_free( in.pvBuffer );
1335  *auth_ptr = NULL;
1336  return FALSE;
1337  }
1338  out_desc.ulVersion = 0;
1339  out_desc.cBuffers = 1;
1340  out_desc.pBuffers = &out;
1341 
1343  first ? request->connect->servername : NULL, flags, 0,
1344  SECURITY_NETWORK_DREP, in.pvBuffer ? &in_desc : NULL, 0,
1345  &authinfo->ctx, &out_desc, &authinfo->attr, &authinfo->exp );
1346  heap_free( in.pvBuffer );
1347  if (status == SEC_E_OK)
1348  {
1349  heap_free( authinfo->data );
1350  authinfo->data = out.pvBuffer;
1351  authinfo->data_len = out.cbBuffer;
1352  authinfo->finished = TRUE;
1353  TRACE("sending last auth packet\n");
1354  }
1355  else if (status == SEC_I_CONTINUE_NEEDED)
1356  {
1357  heap_free( authinfo->data );
1358  authinfo->data = out.pvBuffer;
1359  authinfo->data_len = out.cbBuffer;
1360  TRACE("sending next auth packet\n");
1361  }
1362  else
1363  {
1364  ERR("InitializeSecurityContextW failed with error 0x%08x\n", status);
1365  heap_free( out.pvBuffer );
1367  *auth_ptr = NULL;
1368  return FALSE;
1369  }
1370  break;
1371  }
1372  default:
1373  ERR("invalid scheme %u\n", scheme);
1374  return FALSE;
1375  }
1376  *auth_ptr = authinfo;
1377 
1378  len_scheme = auth_schemes[authinfo->scheme].len;
1379  len = len_scheme + 1 + ((authinfo->data_len + 2) * 4) / 3;
1380  if (!(auth_reply = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
1381 
1382  memcpy( auth_reply, auth_schemes[authinfo->scheme].str, len_scheme * sizeof(WCHAR) );
1383  auth_reply[len_scheme] = ' ';
1384  encode_base64( authinfo->data, authinfo->data_len, auth_reply + len_scheme + 1 );
1385 
1387  ret = process_header( request, auth_target, auth_reply, flags, TRUE );
1388  heap_free( auth_reply );
1389  return ret;
1390 }
#define WINHTTP_QUERY_WWW_AUTHENTICATE
Definition: winhttp.h:338
struct connect * connect
#define TRUE
Definition: types.h:120
#define WINHTTP_QUERY_PROXY_AUTHENTICATE
Definition: winhttp.h:339
#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
WCHAR SEC_WCHAR
Definition: sspi.h:29
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
Definition: sspi.c:699
ULONG ulVersion
Definition: sspi.h:168
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
static const WCHAR attr_proxy_authorization[]
Definition: request.c:86
const GLint * first
Definition: glext.h:5794
#define WARN(fmt,...)
Definition: debug.h:111
#define WINHTTP_ADDREQ_FLAG_REPLACE
Definition: winhttp.h:88
BOOL process_header(struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only)
Definition: request.c:430
#define ISC_REQ_DELEGATE
Definition: sspi.h:349
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
auth_target
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static UINT encode_base64(const char *bin, unsigned int len, WCHAR *base64)
Definition: request.c:1007
struct _test_info info[]
Definition: SetCursorPos.c:19
Definition: cookie.c:41
CredHandle cred
#define CP_UTF8
Definition: nls.h:20
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:2927
static unsigned int decode_base64(const WCHAR *base64, unsigned int len, char *buf)
Definition: request.c:1058
LONG SECURITY_STATUS
Definition: sspi.h:34
static WCHAR username[]
Definition: url.c:32
#define TRACE(s)
Definition: solgame.cpp:4
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
TimeStamp exp
const WCHAR * str
Definition: request.c:890
__wchar_t WCHAR
Definition: xmlstorage.h:180
void destroy_authinfo(struct authinfo *authinfo)
Definition: request.c:1138
#define SEC_WINNT_AUTH_IDENTITY_UNICODE
Definition: rpcdce.h:310
struct request::@580 creds[TARGET_MAX][SCHEME_MAX]
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int data_len
struct authinfo * proxy_authinfo
GLbitfield flags
Definition: glext.h:7161
int ret
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
#define SECBUFFER_TOKEN
Definition: sspi.h:148
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define ISC_REQ_USE_DCE_STYLE
Definition: sspi.h:358
#define SECURITY_NETWORK_DREP
Definition: sspi.h:461
DWORD scheme
#define SEC_E_OK
Definition: winerror.h:2356
#define ISC_REQ_CONNECTION
Definition: sspi.h:360
#define ERR(fmt,...)
Definition: debug.h:109
char * data
GLuint in
Definition: glext.h:9616
static const struct @579 auth_schemes[]
DWORD exp
Definition: msg.c:16038
#define ISC_REQ_MUTUAL_AUTH
Definition: sspi.h:350
struct authinfo * authinfo
DWORD scheme
Definition: request.c:892
Definition: tftpd.h:85
unsigned int ULONG
Definition: retypes.h:1
GLenum GLuint id
Definition: glext.h:5579
GLenum target
Definition: glext.h:7315
static BOOL get_authvalue(struct request *request, DWORD level, DWORD scheme, WCHAR *buffer, DWORD len)
Definition: request.c:1151
auth_scheme
static const WCHAR attr_authorization[]
Definition: request.c:55
static enum auth_scheme scheme_from_flag(DWORD flag)
Definition: request.c:903
#define WINHTTP_AUTH_TARGET_PROXY
Definition: winhttp.h:459
GLfloat GLfloat p
Definition: glext.h:8902
ULONG cBuffers
Definition: sspi.h:169
static SERVICE_STATUS status
Definition: service.c:31
void user(int argc, const char *argv[])
Definition: cmds.c:1350
static struct authinfo * alloc_authinfo(void)
Definition: request.c:1120
ULONG max_token
SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName, PSecPkgInfoW *ppPackageInfo)
Definition: wrapper.c:750
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define WINHTTP_AUTH_TARGET_SERVER
Definition: winhttp.h:458
CtxtHandle ctx
Definition: ps.c:97

Referenced by handle_authorization(), and send_request().

◆ drain_content()

static void drain_content ( struct request request)
static

Definition at line 2063 of file request.c.

2064 {
2065  DWORD size, bytes_read, bytes_total = 0, bytes_left = request->content_length - request->content_read;
2066  char buffer[2048];
2067 
2069  for (;;)
2070  {
2071  if (request->read_chunked) size = sizeof(buffer);
2072  else
2073  {
2074  if (bytes_total >= bytes_left) return;
2075  size = min( sizeof(buffer), bytes_left - bytes_total );
2076  }
2077  if (!read_data( request, buffer, size, &bytes_read, FALSE ) || !bytes_read) return;
2078  bytes_total += bytes_read;
2079  }
2080 }
DWORD content_length
static BOOL refill_buffer(struct request *request, BOOL notify)
Definition: request.c:1951
GLuint buffer
Definition: glext.h:5915
DWORD content_read
BOOL read_chunked
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define min(a, b)
Definition: monoChain.cc:55
Definition: tftpd.h:85
static BOOL read_data(struct request *request, void *buffer, DWORD size, DWORD *read, BOOL async)
Definition: request.c:2018

Referenced by send_request().

◆ encode_base64()

static UINT encode_base64 ( const char bin,
unsigned int  len,
WCHAR base64 
)
static

Definition at line 1007 of file request.c.

1008 {
1009  UINT n = 0, x;
1010  static const char base64enc[] =
1011  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1012 
1013  while (len > 0)
1014  {
1015  /* first 6 bits, all from bin[0] */
1016  base64[n++] = base64enc[(bin[0] & 0xfc) >> 2];
1017  x = (bin[0] & 3) << 4;
1018 
1019  /* next 6 bits, 2 from bin[0] and 4 from bin[1] */
1020  if (len == 1)
1021  {
1022  base64[n++] = base64enc[x];
1023  base64[n++] = '=';
1024  base64[n++] = '=';
1025  break;
1026  }
1027  base64[n++] = base64enc[x | ((bin[1] & 0xf0) >> 4)];
1028  x = (bin[1] & 0x0f) << 2;
1029 
1030  /* next 6 bits 4 from bin[1] and 2 from bin[2] */
1031  if (len == 2)
1032  {
1033  base64[n++] = base64enc[x];
1034  base64[n++] = '=';
1035  break;
1036  }
1037  base64[n++] = base64enc[x | ((bin[2] & 0xc0) >> 6)];
1038 
1039  /* last 6 bits, all from bin [2] */
1040  base64[n++] = base64enc[bin[2] & 0x3f];
1041  bin += 3;
1042  len -= 3;
1043  }
1044  base64[n] = 0;
1045  return n;
1046 }
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 do_authorization().

◆ end_of_read_data()

static BOOL end_of_read_data ( struct request request)
static

Definition at line 2010 of file request.c.

2011 {
2012  if (!request->content_length) return TRUE;
2014  if (request->content_length == ~0u) return FALSE;
2016 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define TRUE
Definition: types.h:120
DWORD content_length
DWORD content_read
BOOL read_chunked
Definition: tftpd.h:85
BOOL read_chunked_eof

Referenced by query_data_available(), and read_data().

◆ ensure_cred_handle()

static BOOL ensure_cred_handle ( struct request request)
static

Definition at line 1605 of file request.c.

1606 {
1608 
1609  if (request->cred_handle_initialized) return TRUE;
1610 
1612  {
1614  memset( &cred, 0, sizeof(cred) );
1615  cred.dwVersion = SCHANNEL_CRED_VERSION;
1616  cred.grbitEnabledProtocols = map_secure_protocols( request->connect->session->secure_protocols );
1617  if (request->client_cert)
1618  {
1619  cred.paCred = &request->client_cert;
1620  cred.cCreds = 1;
1621  }
1623  &cred, NULL, NULL, &request->cred_handle, NULL );
1624  if (status == SEC_E_OK)
1626  }
1627 
1628  if (status != SEC_E_OK)
1629  {
1630  WARN( "AcquireCredentialsHandleW failed: 0x%08x\n", status );
1631  return FALSE;
1632  }
1633  return TRUE;
1634 }
struct connect * connect
#define TRUE
Definition: types.h:120
#define SECPKG_CRED_OUTBOUND
Definition: sspi.h:278
CredHandle cred_handle
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 CERT_CONTEXT * client_cert
#define WARN(fmt,...)
Definition: debug.h:111
static DWORD map_secure_protocols(DWORD mask)
Definition: request.c:1594
BOOL cred_handle_initialized
CredHandle cred
#define SCHANNEL_CRED_VERSION
Definition: schannel.h:22
smooth NULL
Definition: ftsmooth.c:416
LONG SECURITY_STATUS
Definition: sspi.h:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SEC_E_OK
Definition: winerror.h:2356
Definition: tftpd.h:85
#define UNISP_NAME_W
Definition: sspi.h:38
#define memset(x, y, z)
Definition: compat.h:39
Definition: ps.c:97

Referenced by open_connection().

◆ escape_string()

static DWORD escape_string ( const char src,
DWORD  len,
char dst,
enum escape_flags  flags 
)
static

Definition at line 2112 of file request.c.

2113 {
2114  static const char hex[] = "0123456789ABCDEF";
2115  DWORD i, ret = len;
2116  char *ptr = dst;
2117 
2118  for (i = 0; i < len; i++)
2119  {
2120  if ((flags & ESCAPE_FLAG_STRIP_CRLF) && (src[i] == '\r' || src[i] == '\n'))
2121  {
2122  ret--;
2123  continue;
2124  }
2125  if (need_escape( src[i], flags ))
2126  {
2127  if (dst)
2128  {
2129  ptr[0] = '%';
2130  ptr[1] = hex[(src[i] >> 4) & 0xf];
2131  ptr[2] = hex[src[i] & 0xf];
2132  ptr += 3;
2133  }
2134  ret += 2;
2135  }
2136  else if (dst) *ptr++ = src[i];
2137  }
2138 
2139  if (dst) dst[ret] = 0;
2140  return ret;
2141 }
static const char hex[16]
Definition: profile.c:123
static BOOL need_escape(char ch, enum escape_flags flags)
Definition: request.c:2098
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 PVOID ptr
Definition: dispmode.c:27
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
unsigned int len
Definition: request.c:891

Referenced by str_to_wire().

◆ finished_reading()

static void finished_reading ( struct request request)
static

Definition at line 1975 of file request.c.

1976 {
1977  static const WCHAR closeW[] = {'c','l','o','s','e',0};
1978 
1979  BOOL close = FALSE;
1980  WCHAR connection[20];
1981  DWORD size = sizeof(connection);
1982 
1983  if (!request->netconn) return;
1984 
1985  if (request->hdr.disable_flags & WINHTTP_DISABLE_KEEP_ALIVE) close = TRUE;
1986  else if (query_headers( request, WINHTTP_QUERY_CONNECTION, NULL, connection, &size, NULL ) ||
1988  {
1989  if (!strcmpiW( connection, closeW )) close = TRUE;
1990  }
1991  else if (!strcmpW( request->version, http1_0 )) close = TRUE;
1992  if (close)
1993  {
1995  return;
1996  }
1997 
1999  request->netconn = NULL;
2000 }
#define TRUE
Definition: types.h:120
static const WCHAR http1_0[]
#define WINHTTP_QUERY_PROXY_CONNECTION
Definition: winhttp.h:367
#define WINHTTP_DISABLE_KEEP_ALIVE
Definition: winhttp.h:171
WCHAR * version
static void cache_connection(struct netconn *netconn)
Definition: request.c:1556
#define WINHTTP_QUERY_CONNECTION
Definition: winhttp.h:321
unsigned int BOOL
Definition: ntddk_ex.h:94
void close_connection(struct request *request)
Definition: request.c:1809
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define close
Definition: acwin.h:98
#define strcmpiW(s1, s2)
Definition: unicode.h:39
struct object_header hdr
struct netconn * netconn
Definition: tftpd.h:85
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
static BOOL query_headers(struct request *request, DWORD level, const WCHAR *name, void *buffer, DWORD *buflen, DWORD *index)
Definition: request.c:651

Referenced by read_data().

◆ free_header()

static void free_header ( struct header header)
static

Definition at line 297 of file request.c.

298 {
299  heap_free( header->field );
300  heap_free( header->value );
301  heap_free( header );
302 }
WCHAR * field
WCHAR * value
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by add_request_headers(), parse_header(), and read_reply().

◆ free_request()

static void free_request ( struct winhttp_request request)
static

Definition at line 3254 of file request.c.

3255 {
3256  if (request->state < REQUEST_STATE_INITIALIZED) return;
3257  WinHttpCloseHandle( request->hrequest );
3258  WinHttpCloseHandle( request->hconnect );
3259  WinHttpCloseHandle( request->hsession );
3260 #ifdef __REACTOS__
3261  CloseHandle( request->thread );
3262 #else
3263  CloseHandle( request->done );
3264 #endif
3265  CloseHandle( request->wait );
3266  CloseHandle( request->cancel );
3267  heap_free( (WCHAR *)request->proxy.lpszProxy );
3268  heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
3269  heap_free( request->buffer );
3270  heap_free( request->verb );
3271  VariantClear( &request->data );
3272 }
#define CloseHandle
Definition: compat.h:406
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1187
__wchar_t WCHAR
Definition: xmlstorage.h:180
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
WCHAR * verb
Definition: tftpd.h:85
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by winhttp_request_Release().

◆ get_authvalue()

static BOOL get_authvalue ( struct request request,
DWORD  level,
DWORD  scheme,
WCHAR buffer,
DWORD  len 
)
static

Definition at line 1151 of file request.c.

1152 {
1153  DWORD size, index = 0;
1154  for (;;)
1155  {
1156  size = len;
1157  if (!query_headers( request, level, NULL, buffer, &size, &index )) return FALSE;
1158  if (auth_scheme_from_header( buffer ) == scheme) break;
1159  }
1160  return TRUE;
1161 }
GLint level
Definition: gl.h:1546
static DWORD auth_scheme_from_header(const WCHAR *header)
Definition: request.c:911
#define TRUE
Definition: types.h:120
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD scheme
Definition: request.c:892
Definition: tftpd.h:85
static BOOL query_headers(struct request *request, DWORD level, const WCHAR *name, void *buffer, DWORD *buflen, DWORD *index)
Definition: request.c:651
unsigned int len
Definition: request.c:891

Referenced by do_authorization().

◆ get_available_data()

static DWORD get_available_data ( struct request request)
static

Definition at line 2003 of file request.c.

2004 {
2006  return request->read_size;
2007 }
BOOL read_chunked
DWORD read_size
#define min(a, b)
Definition: monoChain.cc:55
Definition: tftpd.h:85
BOOL read_chunked_size

Referenced by query_data_available(), and read_data().

◆ get_header_index()

static int get_header_index ( struct request request,
const WCHAR field,
int  requested_index,
BOOL  request_only 
)
static

Definition at line 376 of file request.c.

377 {
378  int index;
379 
380  TRACE("%s\n", debugstr_w(field));
381 
382  for (index = 0; index < request->num_headers; index++)
383  {
384  if (strcmpiW( request->headers[index].field, field )) continue;
385  if (request_only && !request->headers[index].is_request) continue;
386  if (!request_only && request->headers[index].is_request) continue;
387 
388  if (!requested_index) break;
389  requested_index--;
390  }
391  if (index >= request->num_headers) index = -1;
392  TRACE("returning %d\n", index);
393  return index;
394 }
#define debugstr_w
Definition: kernel32.h:32
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
Definition: parser.c:43
#define index(s, c)
Definition: various.h:29
struct header * headers
#define strcmpiW(s1, s2)
Definition: unicode.h:39
Definition: tftpd.h:85
DWORD num_headers

Referenced by handle_redirect(), process_header(), and query_headers().

◆ get_redirect_url()

static WCHAR* get_redirect_url ( struct request request,
DWORD len 
)
static

Definition at line 2684 of file request.c.

2685 {
2686  DWORD size;
2687  WCHAR *ret;
2688 
2690  if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return NULL;
2691  if (!(ret = heap_alloc( size ))) return NULL;
2692  *len = size / sizeof(WCHAR) - 1;
2694  heap_free( ret );
2695  return NULL;
2696 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
Definition: tftpd.h:85
static BOOL query_headers(struct request *request, DWORD level, const WCHAR *name, void *buffer, DWORD *buflen, DWORD *index)
Definition: request.c:651
#define WINHTTP_QUERY_LOCATION
Definition: winhttp.h:331
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by handle_redirect().

◆ get_typeinfo()

static HRESULT get_typeinfo ( enum type_id  tid,
ITypeInfo **  ret 
)
static

Definition at line 3343 of file request.c.

3344 {
3345  HRESULT hr;
3346 
3347  if (!winhttp_typelib)
3348  {
3349  ITypeLib *typelib;
3350 
3351  hr = LoadRegTypeLib( &LIBID_WinHttp, 5, 1, LOCALE_SYSTEM_DEFAULT, &typelib );
3352  if (FAILED(hr))
3353  {
3354  ERR("LoadRegTypeLib failed: %08x\n", hr);
3355  return hr;
3356  }
3358  ITypeLib_Release( typelib );
3359  }
3360  if (!winhttp_typeinfo[tid])
3361  {
3363 
3364  hr = ITypeLib_GetTypeInfoOfGuid( winhttp_typelib, winhttp_tid_id[tid], &typeinfo );
3365  if (FAILED(hr))
3366  {
3367  ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(winhttp_tid_id[tid]), hr);
3368  return hr;
3369  }
3371  ITypeInfo_Release( typeinfo );
3372  }
3373  *ret = winhttp_typeinfo[tid];
3374  ITypeInfo_AddRef(winhttp_typeinfo[tid]);
3375  return S_OK;
3376 }
static REFIID winhttp_tid_id[]
Definition: request.c:3338
HRESULT hr
Definition: shlfolder.c:183
static ITypeLib * typelib
Definition: apps.c:108
static ITypeLib * winhttp_typelib
Definition: request.c:3335
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
static ITypeInfo * winhttp_typeinfo[last_tid]
Definition: request.c:3336
LONG HRESULT
Definition: typedefs.h:77
#define LOCALE_SYSTEM_DEFAULT
int ret
static ITypeInfo * typeinfo[last_tid]
Definition: apps.c:109
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI LoadRegTypeLib(REFGUID rguid, WORD wVerMajor, WORD wVerMinor, LCID lcid, ITypeLib **ppTLib)
Definition: typelib.c:531
static TfClientId tid

Referenced by winhttp_request_GetIDsOfNames(), winhttp_request_GetTypeInfo(), and winhttp_request_Invoke().

◆ handle_authorization()

static BOOL handle_authorization ( struct request request,
DWORD  status 
)
static

Definition at line 2469 of file request.c.

2470 {
2471  DWORD i, schemes, first, level, target;
2472 
2473  switch (status)
2474  {
2475  case HTTP_STATUS_DENIED:
2478  break;
2479 
2483  break;
2484 
2485  default:
2486  WARN("unhandled status %u\n", status);
2487  return FALSE;
2488  }
2489 
2490  if (!query_auth_schemes( request, level, &schemes, &first )) return FALSE;
2491  if (do_authorization( request, target, first )) return TRUE;
2492 
2493  schemes &= ~first;
2494  for (i = 0; i < ARRAY_SIZE( auth_schemes ); i++)
2495  {
2496  if (!(schemes & auth_schemes[i].scheme)) continue;
2498  }
2499  return FALSE;
2500 }
#define WINHTTP_QUERY_WWW_AUTHENTICATE
Definition: winhttp.h:338
GLint level
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
#define WINHTTP_QUERY_PROXY_AUTHENTICATE
Definition: winhttp.h:339
static BOOL do_authorization(struct request *request, DWORD target, DWORD scheme_flag)
Definition: request.c:1163
const GLint * first
Definition: glext.h:5794
#define WARN(fmt,...)
Definition: debug.h:111
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 HTTP_STATUS_DENIED
Definition: winhttp.h:256
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_PROXY_AUTH_REQ
Definition: winhttp.h:262
#define ARRAY_SIZE(a)
Definition: main.h:24
static const struct @579 auth_schemes[]
DWORD scheme
Definition: request.c:892
Definition: tftpd.h:85
static BOOL query_auth_schemes(struct request *request, DWORD level, DWORD *supported, DWORD *first)
Definition: request.c:923
GLenum target
Definition: glext.h:7315
#define WINHTTP_AUTH_TARGET_PROXY
Definition: winhttp.h:459
#define WINHTTP_AUTH_TARGET_SERVER
Definition: winhttp.h:458
Definition: ps.c:97

Referenced by receive_response().

◆ handle_passport_redirect()

static BOOL handle_passport_redirect ( struct request request)
static

Definition at line 2824 of file request.c.

2825 {
2826  static const WCHAR status401W[] = {'4','0','1',0};
2828  int i, len = strlenW( request->raw_headers );
2829  WCHAR *p = request->raw_headers;
2830 
2831  if (!process_header( request, attr_status, status401W, flags, FALSE )) return FALSE;
2832 
2833  for (i = 0; i < len; i++)
2834  {
2835  if (i <= len - 3 && p[i] == '3' && p[i + 1] == '0' && p[i + 2] == '2')
2836  {
2837  p[i] = '4';
2838  p[i + 2] = '1';
2839  break;
2840  }
2841  }
2842  return TRUE;
2843 }
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
#define WINHTTP_ADDREQ_FLAG_REPLACE
Definition: winhttp.h:88
BOOL process_header(struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only)
Definition: request.c:430
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 const WCHAR attr_status[]
Definition: request.c:94
WCHAR * raw_headers
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
Definition: tftpd.h:85
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int len
Definition: request.c:891

Referenced by receive_response().

◆ handle_redirect()

static BOOL handle_redirect ( struct request request,
DWORD  status 
)
static

Definition at line 2698 of file request.c.

2699 {
2700  BOOL ret = FALSE;
2701  DWORD len, len_loc;
2702  URL_COMPONENTS uc;
2703  struct connect *connect = request->connect;
2705  WCHAR *hostname = NULL, *location;
2706  int index;
2707 
2708  if (!(location = get_redirect_url( request, &len_loc ))) return FALSE;
2709 
2710  memset( &uc, 0, sizeof(uc) );
2711  uc.dwStructSize = sizeof(uc);
2713 
2714  if (!WinHttpCrackUrl( location, len_loc, 0, &uc )) /* assume relative redirect */
2715  {
2716  WCHAR *path, *p;
2717 
2718  if (location[0] == '/')
2719  {
2720  if (!(path = heap_alloc( (len_loc + 1) * sizeof(WCHAR) ))) goto end;
2721  memcpy( path, location, len_loc * sizeof(WCHAR) );
2722  path[len_loc] = 0;
2723  }
2724  else
2725  {
2726  if ((p = strrchrW( request->path, '/' ))) *p = 0;
2727  len = strlenW( request->path ) + 1 + len_loc;
2728  if (!(path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end;
2729  strcpyW( path, request->path );
2730  strcatW( path, slashW );
2731  memcpy( path + strlenW(path), location, len_loc * sizeof(WCHAR) );
2732  path[len_loc] = 0;
2733  }
2734  heap_free( request->path );
2735  request->path = path;
2736 
2738  }
2739  else
2740  {
2742  {
2744  TRACE("redirect from secure page to non-secure page\n");
2745  request->hdr.flags &= ~WINHTTP_FLAG_SECURE;
2746  }
2747  else if (uc.nScheme == INTERNET_SCHEME_HTTPS && !(request->hdr.flags & WINHTTP_FLAG_SECURE))
2748  {
2749  TRACE("redirect from non-secure page to secure page\n");
2750  request->hdr.flags |= WINHTTP_FLAG_SECURE;
2751  }
2752 
2754 
2755  len = uc.dwHostNameLength;
2756  if (!(hostname = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end;
2757  memcpy( hostname, uc.lpszHostName, len * sizeof(WCHAR) );
2758  hostname[len] = 0;
2759 
2760  port = uc.nPort ? uc.nPort : (uc.nScheme == INTERNET_SCHEME_HTTPS ? 443 : 80);
2762  {
2765  connect->hostport = port;
2766  if (!(ret = set_server_for_hostname( connect, hostname, port ))) goto end;
2767 
2769  request->netconn = NULL;
2773  }
2774  else heap_free( hostname );
2775 
2777  if (!(ret = open_connection( request ))) goto end;
2778 
2779  heap_free( request->path );
2780  request->path = NULL;
2781  if (uc.dwUrlPathLength)
2782  {
2784  if (!(request->path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end;
2785  memcpy( request->path, uc.lpszUrlPath, (len + 1) * sizeof(WCHAR) );
2786  request->path[len] = 0;
2787  }
2788  else request->path = strdupW( slashW );
2789  }
2790 
2791  /* remove content-type/length headers */
2794 
2796  {
2797  heap_free( request->verb );
2798  request->verb = strdupW( getW );
2799  request->optional = NULL;
2800  request->optional_len = 0;
2801  }
2802  ret = TRUE;
2803 
2804 end:
2805  heap_free( location );
2806  return ret;
2807 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
DWORD dwHostNameLength
Definition: winhttp.h:470
LPWSTR lpszUrlPath
Definition: winhttp.h:476
#define WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP
Definition: winhttp.h:158
struct connect * connect
#define TRUE
Definition: types.h:120
DWORD content_length
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
DWORD optional_len
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
GLsizei const GLchar ** path
Definition: glext.h:7234
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
DWORD dwUrlPathLength
Definition: winhttp.h:477
#define WINHTTP_ADDREQ_FLAG_REPLACE
Definition: winhttp.h:88
DWORD content_read
static BOOL delete_header(struct request *request, DWORD index)
Definition: request.c:415
GLuint GLuint end
Definition: gl.h:1545
static int get_header_index(struct request *request, const WCHAR *field, int requested_index, BOOL request_only)
Definition: request.c:376
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
BOOL read_chunked
static const WCHAR postW[]
char * hostname
Definition: ftp.c:88
#define WINHTTP_CALLBACK_STATUS_REDIRECT
Definition: winhttp.h:393
WORD INTERNET_PORT
Definition: winhttp.h:38
static const WCHAR getW[]
Definition: object.c:50
DWORD dwSchemeLength
Definition: winhttp.h:467
BOOL set_server_for_hostname(struct connect *connect, const WCHAR *server, INTERNET_PORT port)
Definition: session.c:468
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD read_pos
static const WCHAR attr_content_type[]
Definition: request.c:67
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
INTERNET_SCHEME nScheme
Definition: winhttp.h:468
GLuint index
Definition: glext.h:6031
static const WCHAR attr_content_length[]
Definition: request.c:62
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
BOOL WINAPI WinHttpCrackUrl(LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONENTSW uc)
Definition: url.c:179
INTERNET_PORT serverport
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwExtraInfoLength
Definition: winhttp.h:479
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR * hostname
DWORD read_size
int ret
DWORD dwStructSize
Definition: winhttp.h:465
#define index(s, c)
Definition: various.h:29
#define HTTP_STATUS_REDIRECT_KEEP_VERB
Definition: winhttp.h:254
INTERNET_PORT nPort
Definition: winhttp.h:471
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
void netconn_close(struct netconn *conn)
Definition: net.c:244
LPWSTR lpszHostName
Definition: winhttp.h:469
WCHAR * verb
#define location(file, line)
Definition: kmtest.h:18
#define strcmpiW(s1, s2)
Definition: unicode.h:39
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
INTERNET_PORT hostport
void send_callback(struct object_header *hdr, DWORD status, void *info, DWORD buflen)
Definition: session.c:55
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
struct object_header hdr
struct netconn * netconn
Definition: tftpd.h:85
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
BOOL read_chunked_eof
static WCHAR * get_redirect_url(struct request *request, DWORD *len)
Definition: request.c:2684
void * optional
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int len
Definition: request.c:891
USHORT port
Definition: uri.c:228
#define memset(x, y, z)
Definition: compat.h:39
static BOOL add_host_header(struct request *request, DWORD modifier)
Definition: request.c:1819
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static BOOL open_connection(struct request *request)
Definition: request.c:1636
Definition: ps.c:97
static const WCHAR slashW[]
Definition: devenum.c:59

Referenced by receive_response().

◆ impl_from_IStream()

static struct stream* impl_from_IStream ( IStream iface)
inlinestatic

Definition at line 4383 of file request.c.

4384 {
4385  return CONTAINING_RECORD( iface, struct stream, IStream_iface );
4386 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Definition: parse.h:22

Referenced by stream_AddRef(), stream_QueryInterface(), stream_Read(), stream_Release(), and stream_Seek().

◆ impl_from_IWinHttpRequest()

◆ initialize_request()

static void initialize_request ( struct winhttp_request request)
static

Definition at line 3589 of file request.c.

3590 {
3591  request->wait = CreateEventW( NULL, FALSE, FALSE, NULL );
3592  request->cancel = CreateEventW( NULL, FALSE, FALSE, NULL );
3593 #ifndef __REACTOS__
3594  request->done = CreateEventW( NULL, FALSE, FALSE, NULL );
3595 #endif
3596  request->connect_timeout = 60000;
3597  request->send_timeout = 30000;
3598  request->receive_timeout = 30000;
3599  request->url_codepage = CP_UTF8;
3600  VariantInit( &request->data );
3602 }
int receive_timeout
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define CP_UTF8
Definition: nls.h:20
int send_timeout
int connect_timeout
smooth NULL
Definition: ftsmooth.c:416
Definition: tftpd.h:85

Referenced by WinHttpRequest_create().

◆ insert_header()

static BOOL insert_header ( struct request request,
struct header header 
)
static

Definition at line 396 of file request.c.

397 {
399  struct header *hdrs;
400 
401  if (request->headers)
402  hdrs = heap_realloc_zero( request->headers, sizeof(struct header) * count );
403  else
404  hdrs = heap_alloc_zero( sizeof(struct header) );
405  if (!hdrs) return FALSE;
406 
407  request->headers = hdrs;
408  request->headers[count - 1].field = strdupW( header->field );
409  request->headers[count - 1].value = strdupW( header->value );
410  request->headers[count - 1].is_request = header->is_request;
412  return TRUE;
413 }
#define TRUE
Definition: types.h:120
BOOL is_request
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
GLuint GLuint GLsizei count
Definition: gl.h:1545
WCHAR * field
WCHAR * value
unsigned long DWORD
Definition: ntddk_ex.h:95
struct header * headers
Definition: tftpd.h:85
DWORD num_headers

Referenced by process_header().

◆ is_passport_request()

static BOOL is_passport_request ( struct request request)
static

Definition at line 2809 of file request.c.

2810 {
2811  static const WCHAR passportW[] = {'P','a','s','s','p','o','r','t','1','.','4'};
2812  WCHAR buf[1024];
2813  DWORD len = ARRAY_SIZE(buf);
2814 
2815  if (!(request->connect->session->passport_flags & WINHTTP_ENABLE_PASSPORT_AUTH) ||
2817 
2819  (buf[ARRAY_SIZE(passportW)] == ' ' || !buf[ARRAY_SIZE(passportW)])) return TRUE;
2820 
2821  return FALSE;
2822 }
#define WINHTTP_QUERY_WWW_AUTHENTICATE
Definition: winhttp.h:338
struct connect * connect
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR passportW[]
Definition: request.c:884
#define ARRAY_SIZE(a)
Definition: main.h:24
Definition: tftpd.h:85
static BOOL query_headers(struct request *request, DWORD level, const WCHAR *name, void *buffer, DWORD *buflen, DWORD *index)
Definition: request.c:651
#define WINHTTP_ENABLE_PASSPORT_AUTH
Definition: winhttp.h:164

Referenced by receive_response().

◆ map_secure_protocols()

static DWORD map_secure_protocols ( DWORD  mask)
static

Definition at line 1594 of file request.c.

1595 {
1596  DWORD ret = 0;
1602  return ret;
1603 }
#define SP_PROT_SSL3_CLIENT
Definition: schannel.h:30
#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2
Definition: winhttp.h:447
#define SP_PROT_TLS1_CLIENT
Definition: schannel.h:31
#define SP_PROT_TLS1_1_CLIENT
Definition: schannel.h:33
#define WINHTTP_FLAG_SECURE_PROTOCOL_SSL3
Definition: winhttp.h:444
#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1
Definition: winhttp.h:446
#define SP_PROT_TLS1_2_CLIENT
Definition: schannel.h:34
GLenum GLint GLuint mask
Definition: glext.h:6028
#define WINHTTP_FLAG_SECURE_PROTOCOL_SSL2
Definition: winhttp.h:443
#define SP_PROT_SSL2_CLIENT
Definition: schannel.h:29
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1
Definition: winhttp.h:445

Referenced by ensure_cred_handle().

◆ need_escape()

static BOOL need_escape ( char  ch,
enum escape_flags  flags 
)
inlinestatic

Definition at line 2098 of file request.c.

2099 {
2100  static const char unsafe[] = "\"#<>[\\]^`{|}";
2101  const char *ptr = unsafe;
2102 
2103  if ((flags & ESCAPE_FLAG_SPACE) && ch == ' ') return TRUE;
2104  if ((flags & ESCAPE_FLAG_PERCENT) && ch == '%') return TRUE;
2105  if ((flags & ESCAPE_FLAG_NON_PRINTABLE) && ch < 0x20) return TRUE;
2106  if ((flags & ESCAPE_FLAG_DEL) && ch == 0x7f) return TRUE;
2107  if ((flags & ESCAPE_FLAG_8BIT) && (ch & 0x80)) return TRUE;
2108  if ((flags & ESCAPE_FLAG_UNSAFE)) while (*ptr) { if (ch == *ptr++) return TRUE; }
2109  return FALSE;
2110 }
#define TRUE
Definition: types.h:120
static PVOID ptr
Definition: dispmode.c:27
GLbitfield flags
Definition: glext.h:7161

Referenced by escape_string().

◆ open_connection()

static BOOL open_connection ( struct request request)
static

Definition at line 1636 of file request.c.

1637 {
1639  struct hostdata *host = NULL, *iter;
1640  struct netconn *netconn = NULL;
1641  struct connect *connect;
1642  WCHAR *addressW = NULL;
1644  DWORD len;
1645 
1646  if (request->netconn) goto done;
1647 
1648  connect = request->connect;
1649  port = connect->serverport ? connect->serverport : (request->hdr.flags & WINHTTP_FLAG_SECURE ? 443 : 80);
1650 
1652 
1654  {
1655  if (iter->port == port && !strcmpW( connect->servername, iter->hostname ) && !is_secure == !iter->secure)
1656  {
1657  host = iter;
1658  host->ref++;
1659  break;
1660  }
1661  }
1662 
1663  if (!host)
1664  {
1665  if ((host = heap_alloc( sizeof(*host) )))
1666  {
1667  host->ref = 1;
1668  host->secure = is_secure;
1669  host->port = port;
1670  list_init( &host->connections );
1671  if ((host->hostname = strdupW( connect->servername )))
1672  {
1673  list_add_head( &connection_pool, &host->entry );
1674  }
1675  else
1676  {
1677  heap_free( host );
1678  host = NULL;
1679  }
1680  }
1681  }
1682 
1684 
1685  if (!host) return FALSE;
1686 
1687  for (;;)
1688  {
1690  if (!list_empty( &host->connections ))
1691  {
1692  netconn = LIST_ENTRY( list_head( &host->connections ), struct netconn, entry );
1693  list_remove( &netconn->entry );
1694  }
1696  if (!netconn) break;
1697 
1698  if (netconn_is_alive( netconn )) break;
1699  TRACE("connection %p no longer alive, closing\n", netconn);
1701  netconn = NULL;
1702  }
1703 
1704  if (!connect->resolved && netconn)
1705  {
1707  connect->resolved = TRUE;
1708  }
1709 
1710  if (!connect->resolved)
1711  {
1712  len = strlenW( host->hostname ) + 1;
1714 
1716  {
1717  release_host( host );
1718  return FALSE;
1719  }
1720  connect->resolved = TRUE;
1721 
1722  if (!(addressW = addr_to_str( &connect->sockaddr )))
1723  {
1724  release_host( host );
1725  return FALSE;
1726  }
1727  len = strlenW( addressW ) + 1;
1729  }
1730 
1731  if (!netconn)
1732  {
1733  if (!addressW && !(addressW = addr_to_str( &connect->sockaddr )))
1734  {
1735  release_host( host );
1736  return FALSE;
1737  }
1738 
1739  TRACE("connecting to %s:%u\n", debugstr_w(addressW), port);
1740 
1742 
1744  {
1745  heap_free( addressW );
1746  release_host( host );
1747  return FALSE;
1748  }
1751 
1752  request->netconn = netconn;
1753 
1754  if (is_secure)
1755  {
1756  if (connect->session->proxy_server &&
1758  {
1759  if (!secure_proxy_connect( request ))
1760  {
1761  request->netconn = NULL;
1762  heap_free( addressW );
1764  return FALSE;
1765  }
1766  }
1767 
1769  request->