ReactOS  0.4.13-dev-66-gc714b7f
request.c File Reference
#include "config.h"
#include "wine/port.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 "winhttp_private.h"
#include "wine/debug.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 ARRAYSIZE(array)   (sizeof(array) / sizeof((array)[0]))
 
#define INET6_ADDRSTRLEN   46
 
#define MAX_REPLY_LEN   1460
 
#define INITIAL_HEADER_BUFFER_LEN   512
 

Enumerations

enum  request_state {
  REQUEST_STATE_UNINITIALIZED, 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, 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 task_header_tdequeue_task (request_t *request)
 
static DWORD CALLBACK task_proc (LPVOID param)
 
static BOOL queue_task (task_header_t *task)
 
static void free_header (header_t *header)
 
static BOOL valid_token_char (WCHAR c)
 
static header_tparse_header (LPCWSTR string)
 
static int get_header_index (request_t *request, LPCWSTR field, int requested_index, BOOL request_only)
 
static BOOL insert_header (request_t *request, header_t *header)
 
static BOOL delete_header (request_t *request, DWORD index)
 
BOOL process_header (request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only)
 
BOOL add_request_headers (request_t *request, LPCWSTR headers, DWORD len, DWORD flags)
 
BOOL WINAPI WinHttpAddRequestHeaders (HINTERNET hrequest, LPCWSTR headers, DWORD len, DWORD flags)
 
static WCHARbuild_request_path (request_t *request)
 
static WCHARbuild_request_string (request_t *request)
 
static BOOL query_headers (request_t *request, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD 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 (WCHAR *header)
 
static BOOL query_auth_schemes (request_t *request, DWORD level, LPDWORD supported, LPDWORD 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 (request_t *request, DWORD level, DWORD scheme, WCHAR *buffer, DWORD len)
 
static BOOL do_authorization (request_t *request, DWORD target, DWORD scheme_flag)
 
static LPWSTR concatenate_string_list (LPCWSTR *list, int len)
 
static LPWSTR build_header_request_string (request_t *request, LPCWSTR verb, LPCWSTR path, LPCWSTR version)
 
static BOOL read_reply (request_t *request)
 
static BOOL secure_proxy_connect (request_t *request)
 
static WCHARaddr_to_str (struct sockaddr_storage *addr)
 
void release_host (hostdata_t *host)
 
static DWORD WINAPI connection_collector (void *arg)
 
static void cache_connection (netconn_t *netconn)
 
static DWORD map_secure_protocols (DWORD mask)
 
static BOOL ensure_cred_handle (session_t *session)
 
static BOOL open_connection (request_t *request)
 
void close_connection (request_t *request)
 
static BOOL add_host_header (request_t *request, DWORD modifier)
 
static void clear_response_headers (request_t *request)
 
static void remove_data (request_t *request, int count)
 
static BOOL read_more_data (request_t *request, int maxlen, BOOL notify)
 
static BOOL discard_eol (request_t *request, BOOL notify)
 
static BOOL start_next_chunk (request_t *request, BOOL notify)
 
static BOOL refill_buffer (request_t *request, BOOL notify)
 
static void finished_reading (request_t *request)
 
static DWORD get_available_data (request_t *request)
 
static BOOL end_of_read_data (request_t *request)
 
static BOOL read_data (request_t *request, void *buffer, DWORD size, DWORD *read, BOOL async)
 
static void drain_content (request_t *request)
 
static BOOL send_request (request_t *request, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context, BOOL async)
 
static void task_send_request (task_header_t *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 (request_t *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 (request_t *request, DWORD status)
 
static DWORD set_content_length (request_t *request, DWORD status)
 
static BOOL read_line (request_t *request, char *buffer, DWORD *len)
 
static void record_cookies (request_t *request)
 
static WCHARget_redirect_url (request_t *request, DWORD *len)
 
static BOOL handle_redirect (request_t *request, DWORD status)
 
static BOOL receive_response (request_t *request, BOOL async)
 
static void task_receive_response (task_header_t *task)
 
BOOL WINAPI WinHttpReceiveResponse (HINTERNET hrequest, LPVOID reserved)
 
static BOOL query_data_available (request_t *request, DWORD *available, BOOL async)
 
static void task_query_data_available (task_header_t *task)
 
BOOL WINAPI WinHttpQueryDataAvailable (HINTERNET hrequest, LPDWORD available)
 
static void task_read_data (task_header_t *task)
 
BOOL WINAPI WinHttpReadData (HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
 
static BOOL write_data (request_t *request, LPCVOID buffer, DWORD to_write, LPDWORD written, BOOL async)
 
static void task_write_data (task_header_t *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 HRESULT request_send_and_receive (struct winhttp_request *request)
 
static DWORD CALLBACK send_and_receive_proc (void *arg)
 
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 const unsigned int num_auth_schemes = sizeof(auth_schemes)/sizeof(auth_schemes[0])
 
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

◆ ARRAYSIZE

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

Definition at line 858 of file request.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file request.c.

◆ DEFAULT_KEEP_ALIVE_TIMEOUT

#define DEFAULT_KEEP_ALIVE_TIMEOUT   30000

Definition at line 51 of file request.c.

◆ INET6_ADDRSTRLEN

#define INET6_ADDRSTRLEN   46

Definition at line 1491 of file request.c.

◆ INITIAL_HEADER_BUFFER_LEN

#define INITIAL_HEADER_BUFFER_LEN   512

Definition at line 2387 of file request.c.

◆ MAX_REPLY_LEN

#define MAX_REPLY_LEN   1460

Definition at line 2386 of file request.c.

◆ QUERY_MODIFIER_MASK

Enumeration Type Documentation

◆ request_state

Enumerator
REQUEST_STATE_UNINITIALIZED 
REQUEST_STATE_INITIALIZED 
REQUEST_STATE_CANCELLED 
REQUEST_STATE_OPEN 
REQUEST_STATE_SENT 
REQUEST_STATE_RESPONSE_RECEIVED 

Definition at line 2924 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 
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 3068 of file request.c.

3069 {
3071  last_tid
3072 };

Function Documentation

◆ add_host_header()

static BOOL add_host_header ( request_t request,
DWORD  modifier 
)
static

Definition at line 1813 of file request.c.

1814 {
1815  BOOL ret;
1816  DWORD len;
1817  WCHAR *host;
1818  static const WCHAR fmt[] = {'%','s',':','%','u',0};
1819  connect_t *connect = request->connect;
1821 
1822  port = connect->hostport ? connect->hostport : (request->hdr.flags & WINHTTP_FLAG_SECURE ? 443 : 80);
1823 
1825  {
1826  return process_header( request, attr_host, connect->hostname, modifier, TRUE );
1827  }
1828  len = strlenW( connect->hostname ) + 7; /* sizeof(":65335") */
1829  if (!(host = heap_alloc( len * sizeof(WCHAR) ))) return FALSE;
1830  sprintfW( host, fmt, connect->hostname, port );
1831  ret = process_header( request, attr_host, host, modifier, TRUE );
1832  heap_free( host );
1833  return ret;
1834 }
#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
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
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
int ret
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR attr_host[]
Definition: request.c:79
#define INTERNET_DEFAULT_HTTPS_PORT
Definition: winhttp.h:37
#define sprintfW
Definition: unicode.h:58
BOOL process_header(request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only)
Definition: request.c:409
Definition: tftpd.h:85
unsigned int len
Definition: request.c:869
USHORT port
Definition: uri.c:227
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 ( request_t request,
LPCWSTR  headers,
DWORD  len,
DWORD  flags 
)

Definition at line 474 of file request.c.

475 {
476  BOOL ret = FALSE;
477  WCHAR *buffer, *p, *q;
478  header_t *header;
479 
480  if (len == ~0u) len = strlenW( headers );
481  if (!len) return TRUE;
482  if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
483  memcpy( buffer, headers, len * sizeof(WCHAR) );
484  buffer[len] = 0;
485 
486  p = buffer;
487  do
488  {
489  q = p;
490  while (*q)
491  {
492  if (q[0] == '\n' && q[1] == '\r')
493  {
494  q[0] = '\r';
495  q[1] = '\n';
496  }
497  if (q[0] == '\r' && q[1] == '\n') break;
498  q++;
499  }
500  if (!*p) break;
501  if (*q == '\r')
502  {
503  *q = 0;
504  q += 2; /* jump over \r\n */
505  }
506  if ((header = parse_header( p )))
507  {
508  ret = process_header( request, header->field, header->value, flags, TRUE );
509  free_header( header );
510  }
511  p = q;
512  } while (ret);
513 
514  heap_free( buffer );
515  return ret;
516 }
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
static header_t * parse_header(LPCWSTR string)
Definition: request.c:305
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLuint buffer
Definition: glext.h:5915
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_t WCHAR
Definition: xmlstorage.h:180
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
static void free_header(header_t *header)
Definition: request.c:277
BOOL process_header(request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only)
Definition: request.c:409
Definition: tftpd.h:85
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int len
Definition: request.c:869
struct CFHEADER header
Definition: fdi.c:109
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 1494 of file request.c.

1495 {
1496  char buf[INET6_ADDRSTRLEN];
1497  void *src;
1498 
1499  switch (addr->ss_family)
1500  {
1501  case AF_INET:
1502  src = &((struct sockaddr_in *)addr)->sin_addr;
1503  break;
1504  case AF_INET6:
1505  src = &((struct sockaddr_in6 *)addr)->sin6_addr;
1506  break;
1507  default:
1508  WARN("unsupported address family %d\n", addr->ss_family);
1509  return NULL;
1510  }
1511  if (!inet_ntop( addr->ss_family, src, buf, sizeof(buf) )) return NULL;
1512  return strdupAW( buf );
1513 }
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:96
#define INET6_ADDRSTRLEN
Definition: request.c:1491
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 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 1099 of file request.c.

1100 {
1101  struct authinfo *ret;
1102 
1103  if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
1104 
1105  SecInvalidateHandle( &ret->cred );
1106  SecInvalidateHandle( &ret->ctx );
1107  memset( &ret->exp, 0, sizeof(ret->exp) );
1108  ret->scheme = 0;
1109  ret->attr = 0;
1110  ret->max_token = 0;
1111  ret->data = NULL;
1112  ret->data_len = 0;
1113  ret->finished = FALSE;
1114  return ret;
1115 }
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 ( WCHAR header)
static

Definition at line 890 of file request.c.

891 {
892  unsigned int i;
893 
894  for (i = 0; i < num_auth_schemes; i++)
895  {
897  (header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
898  }
899  return 0;
900 }
#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
static const struct @561 auth_schemes[]
const WCHAR * str
Definition: request.c:868
GLenum GLsizei len
Definition: glext.h:6722
static const unsigned int num_auth_schemes
Definition: request.c:880
struct CFHEADER header
Definition: fdi.c:109

Referenced by get_authvalue(), and query_auth_schemes().

◆ build_header_request_string()

static LPWSTR build_header_request_string ( request_t request,
LPCWSTR  verb,
LPCWSTR  path,
LPCWSTR  version 
)
static

Definition at line 1390 of file request.c.

1392 {
1393  static const WCHAR crlf[] = {'\r','\n',0};
1394  static const WCHAR space[] = { ' ',0 };
1395  static const WCHAR colon[] = { ':',' ',0 };
1396  static const WCHAR twocrlf[] = {'\r','\n','\r','\n', 0};
1397  LPWSTR requestString;
1398  DWORD len, n;
1399  LPCWSTR *req;
1400  UINT i;
1401  LPWSTR p;
1402 
1403  /* allocate space for an array of all the string pointers to be added */
1404  len = (request->num_headers) * 4 + 10;
1405  req = heap_alloc( len * sizeof(LPCWSTR) );
1406  if (!req) return NULL;
1407 
1408  /* add the verb, path and HTTP version string */
1409  n = 0;
1410  req[n++] = verb;
1411  req[n++] = space;
1412  req[n++] = path;
1413  req[n++] = space;
1414  req[n++] = version;
1415 
1416  /* Append custom request headers */
1417  for (i = 0; i < request->num_headers; i++)
1418  {
1419  if (request->headers[i].is_request)
1420  {
1421  req[n++] = crlf;
1422  req[n++] = request->headers[i].field;
1423  req[n++] = colon;
1424  req[n++] = request->headers[i].value;
1425 
1426  TRACE("Adding custom header %s (%s)\n",
1427  debugstr_w(request->headers[i].field),
1428  debugstr_w(request->headers[i].value));
1429  }
1430  }
1431 
1432  if( n >= len )
1433  ERR("oops. buffer overrun\n");
1434 
1435  req[n] = NULL;
1436  requestString = concatenate_string_list( req, 4 );
1437  heap_free( req );
1438  if (!requestString) return NULL;
1439 
1440  /*
1441  * Set (header) termination string for request
1442  * Make sure there are exactly two new lines at the end of the request
1443  */
1444  p = &requestString[strlenW(requestString)-1];
1445  while ( (*p == '\n') || (*p == '\r') )
1446  p--;
1447  strcpyW( p+1, twocrlf );
1448 
1449  return requestString;
1450 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
GLsizei const GLchar ** path
Definition: glext.h:7234
GLdouble n
Definition: glext.h:7729
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:64
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:109
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
unsigned int UINT
Definition: ndis.h:50
Definition: tftpd.h:85
static const WCHAR crlf[]
Definition: object.c:1018
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned int len
Definition: request.c:869
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static LPWSTR concatenate_string_list(LPCWSTR *list, int len)
Definition: request.c:1371

Referenced by secure_proxy_connect().

◆ build_request_path()

static WCHAR* build_request_path ( request_t request)
static

Definition at line 552 of file request.c.

553 {
554  WCHAR *ret;
555 
556  if (strcmpiW( request->connect->hostname, request->connect->servername ))
557  {
558  static const WCHAR http[] = { 'h','t','t','p',0 };
559  static const WCHAR https[] = { 'h','t','t','p','s',0 };
560  static const WCHAR fmt[] = { '%','s',':','/','/','%','s',0 };
561  LPCWSTR scheme = (request->netconn ? request->netconn->secure : (request->hdr.flags & WINHTTP_FLAG_SECURE)) ? https : http;
562  int len;
563 
564  len = strlenW( scheme ) + strlenW( request->connect->hostname );
565  /* 3 characters for '://', 1 for NUL. */
566  len += 4;
567  if (request->connect->hostport)
568  {
569  /* 1 for ':' between host and port, up to 5 for port */
570  len += 6;
571  }
572  if (request->path)
573  len += strlenW( request->path );
574  if ((ret = heap_alloc( len * sizeof(WCHAR) )))
575  {
576  sprintfW( ret, fmt, scheme, request->connect->hostname );
577  if (request->connect->hostport)
578  {
579  static const WCHAR colonFmt[] = { ':','%','u',0 };
580 
581  sprintfW( ret + strlenW( ret ), colonFmt,
582  request->connect->hostport );
583  }
584  if (request->path)
585  strcatW( ret, request->path );
586  }
587  }
588  else
589  ret = request->path;
590  return ret;
591 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
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
#define strcmpiW(s1, s2)
Definition: unicode.h:39
static WCHAR http[]
Definition: url.c:30
#define sprintfW
Definition: unicode.h:58
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
DWORD scheme
Definition: request.c:870
Definition: tftpd.h:85
unsigned int len
Definition: request.c:869
Definition: dsound.c:943

Referenced by build_request_string().

◆ build_request_string()

static WCHAR* build_request_string ( request_t request)
static

Definition at line 593 of file request.c.

594 {
595  static const WCHAR space[] = {' ',0};
596  static const WCHAR crlf[] = {'\r','\n',0};
597  static const WCHAR colon[] = {':',' ',0};
598  static const WCHAR twocrlf[] = {'\r','\n','\r','\n',0};
599 
600  WCHAR *path, *ret;
601  const WCHAR **headers, **p;
602  unsigned int len, i = 0, j;
603 
604  /* allocate space for an array of all the string pointers to be added */
605  len = request->num_headers * 4 + 7;
606  if (!(headers = heap_alloc( len * sizeof(LPCWSTR) ))) return NULL;
607 
609  headers[i++] = request->verb;
610  headers[i++] = space;
611  headers[i++] = path;
612  headers[i++] = space;
613  headers[i++] = request->version;
614 
615  for (j = 0; j < request->num_headers; j++)
616  {
617  if (request->headers[j].is_request)
618  {
619  headers[i++] = crlf;
620  headers[i++] = request->headers[j].field;
621  headers[i++] = colon;
622  headers[i++] = request->headers[j].value;
623 
624  TRACE("adding header %s (%s)\n", debugstr_w(request->headers[j].field),
625  debugstr_w(request->headers[j].value));
626  }
627  }
628  headers[i++] = twocrlf;
629  headers[i] = NULL;
630 
631  len = 0;
632  for (p = headers; *p; p++) len += strlenW( *p );
633  len++;
634 
635  if (!(ret = heap_alloc( len * sizeof(WCHAR) )))
636  goto out;
637  *ret = 0;
638  for (p = headers; *p; p++) strcatW( ret, *p );
639 
640 out:
641  if (path != request->path)
642  heap_free( path );
643  heap_free( headers );
644  return ret;
645 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
GLsizei const GLchar ** path
Definition: glext.h:7234
vector< Header * > headers
Definition: sdkparse.cpp:39
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_w
Definition: kernel32.h:32
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
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 GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static FILE * out
Definition: regtests2xml.c:44
int ret
GLenum GLsizei len
Definition: glext.h:6722
static WCHAR * build_request_path(request_t *request)
Definition: request.c:552
Definition: services.c:325
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
Definition: tftpd.h:85
static const WCHAR crlf[]
Definition: object.c:1018
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int len
Definition: request.c:869
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by query_headers(), and send_request().

◆ cache_connection()

static void cache_connection ( netconn_t netconn)
static

Definition at line 1583 of file request.c.

1584 {
1585  TRACE( "caching connection %p\n", netconn );
1586 
1588 
1590  list_add_head( &netconn->host->connections, &netconn->entry );
1591 
1593  {
1594  HMODULE module;
1595  HANDLE thread;
1596 
1597  GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const WCHAR*)winhttp_instance, &module );
1598 
1600  if (thread)
1601  {
1602  CloseHandle( thread );
1604  }
1605  else
1606  {
1608  }
1609  }
1610 
1612 }
struct list connections
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
HMODULE module
Definition: main.cpp:47
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
static DWORD WINAPI connection_collector(void *arg)
Definition: request.c:1542
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
static CRITICAL_SECTION connection_pool_cs
Definition: request.c:1515
#define DEFAULT_KEEP_ALIVE_TIMEOUT
Definition: request.c:51
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:112
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:405
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HANDLE thread
Definition: service.c:33
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:873
hostdata_t * host
static BOOL connection_collector_running
Definition: request.c:1540
ULONGLONG keep_until
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
HINSTANCE winhttp_instance
Definition: main.c:33
struct list entry

Referenced by finished_reading().

◆ cancel_request()

static void cancel_request ( struct winhttp_request request)
static

Definition at line 2977 of file request.c.

2978 {
2979  if (request->state <= REQUEST_STATE_CANCELLED) return;
2980 
2981  SetEvent( request->cancel );
2982  LeaveCriticalSection( &request->cs );
2983  WaitForSingleObject( request->thread, INFINITE );
2984  EnterCriticalSection( &request->cs );
2985 
2987 
2988  CloseHandle( request->thread );
2989  request->thread = NULL;
2990  CloseHandle( request->wait );
2991  request->wait = NULL;
2992  CloseHandle( request->cancel );
2993  request->cancel = NULL;
2994 }
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
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 ( request_t request)
static

Definition at line 1836 of file request.c.

1837 {
1838  unsigned int i;
1839 
1840  for (i = 0; i < request->num_headers; i++)
1841  {
1842  if (!request->headers[i].field) continue;
1843  if (!request->headers[i].value) continue;
1844  if (request->headers[i].is_request) continue;
1845  delete_header( request, i );
1846  i--;
1847  }
1848 }
static BOOL delete_header(request_t *request, DWORD index)
Definition: request.c:395
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
Definition: tftpd.h:85

Referenced by send_request().

◆ close_connection()

void close_connection ( request_t request)

Definition at line 1803 of file request.c.

1804 {
1805  if (!request->netconn) return;
1806 
1808  netconn_close( request->netconn );
1809  request->netconn = NULL;
1811 }
void send_callback(object_header_t *hdr, DWORD status, LPVOID info, DWORD buflen)
Definition: session.c:71
#define WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION
Definition: winhttp.h:388
smooth NULL
Definition: ftsmooth.c:416
Definition: tftpd.h:85
#define WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED
Definition: winhttp.h:389
BOOL netconn_close(netconn_t *conn)
Definition: net.c:405

Referenced by finished_reading(), and release_object().

◆ concatenate_string_list()

static LPWSTR concatenate_string_list ( LPCWSTR list,
int  len 
)
static

Definition at line 1371 of file request.c.

1372 {
1373  LPCWSTR *t;
1374  LPWSTR str;
1375 
1376  for( t = list; *t ; t++ )
1377  len += strlenW( *t );
1378  len++;
1379 
1380  str = heap_alloc( len * sizeof(WCHAR) );
1381  if (!str) return NULL;
1382  *str = 0;
1383 
1384  for( t = list; *t ; t++ )
1385  strcatW( str, *t );
1386 
1387  return str;
1388 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
GLdouble GLdouble t
Definition: gl.h:2047
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
const WCHAR * str
Definition: request.c:868
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
Definition: _list.h:228
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by build_header_request_string().

◆ connection_collector()

static DWORD WINAPI connection_collector ( void arg)
static

Definition at line 1542 of file request.c.

1543 {
1544  unsigned int remaining_connections;
1545  netconn_t *netconn, *next_netconn;
1546  hostdata_t *host, *next_host;
1547  ULONGLONG now;
1548 
1549  do
1550  {
1551  /* FIXME: Use more sophisticated method */
1552  Sleep(5000);
1553  remaining_connections = 0;
1554  now = GetTickCount64();
1555 
1557 
1559  {
1560  LIST_FOR_EACH_ENTRY_SAFE(netconn, next_netconn, &host->connections, netconn_t, entry)
1561  {
1562  if (netconn->keep_until < now)
1563  {
1564  TRACE("freeing %p\n", netconn);
1565  list_remove(&netconn->entry);
1566  netconn_close(netconn);
1567  }
1568  else
1569  {
1570  remaining_connections++;
1571  }
1572  }
1573  }
1574 
1575  if (!remaining_connections) connection_collector_running = FALSE;
1576 
1578  } while(remaining_connections);
1579 
1581 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
uint8_t entry
Definition: isohybrid.c:63
char * host
Definition: whois.c:55
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
static CRITICAL_SECTION connection_pool_cs
Definition: request.c:1515
VOID WINAPI FreeLibraryAndExitThread(HMODULE hLibModule, DWORD dwExitCode)
Definition: loader.c:514
static struct list connection_pool
Definition: request.c:1524
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
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
static BOOL connection_collector_running
Definition: request.c:1540
ULONGLONG keep_until
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
BOOL netconn_close(netconn_t *conn)
Definition: net.c:405
HINSTANCE winhttp_instance
Definition: main.c:33
struct list entry

Referenced by cache_connection().

◆ decode_base64()

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

Definition at line 1037 of file request.c.

1038 {
1039  unsigned int i = 0;
1040  char c0, c1, c2, c3;
1041  const WCHAR *p = base64;
1042 
1043  while (len > 4)
1044  {
1045  if ((c0 = decode_char( p[0] )) > 63) return 0;
1046  if ((c1 = decode_char( p[1] )) > 63) return 0;
1047  if ((c2 = decode_char( p[2] )) > 63) return 0;
1048  if ((c3 = decode_char( p[3] )) > 63) return 0;
1049 
1050  if (buf)
1051  {
1052  buf[i + 0] = (c0 << 2) | (c1 >> 4);
1053  buf[i + 1] = (c1 << 4) | (c2 >> 2);
1054  buf[i + 2] = (c2 << 6) | c3;
1055  }
1056  len -= 4;
1057  i += 3;
1058  p += 4;
1059  }
1060  if (p[2] == '=')
1061  {
1062  if ((c0 = decode_char( p[0] )) > 63) return 0;
1063  if ((c1 = decode_char( p[1] )) > 63) return 0;
1064 
1065  if (buf) buf[i] = (c0 << 2) | (c1 >> 4);
1066  i++;
1067  }
1068  else if (p[3] == '=')
1069  {
1070  if ((c0 = decode_char( p[0] )) > 63) return 0;
1071  if ((c1 = decode_char( p[1] )) > 63) return 0;
1072  if ((c2 = decode_char( p[2] )) > 63) return 0;
1073 
1074  if (buf)
1075  {
1076  buf[i + 0] = (c0 << 2) | (c1 >> 4);
1077  buf[i + 1] = (c1 << 4) | (c2 >> 2);
1078  }
1079  i += 2;
1080  }
1081  else
1082  {
1083  if ((c0 = decode_char( p[0] )) > 63) return 0;
1084  if ((c1 = decode_char( p[1] )) > 63) return 0;
1085  if ((c2 = decode_char( p[2] )) > 63) return 0;
1086  if ((c3 = decode_char( p[3] )) > 63) return 0;
1087 
1088  if (buf)
1089  {
1090  buf[i + 0] = (c0 << 2) | (c1 >> 4);
1091  buf[i + 1] = (c1 << 4) | (c2 >> 2);
1092  buf[i + 2] = (c2 << 6) | c3;
1093  }
1094  i += 3;
1095  }
1096  return i;
1097 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static char decode_char(WCHAR c)
Definition: request.c:1027
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 1027 of file request.c.

1028 {
1029  if (c >= 'A' && c <= 'Z') return c - 'A';
1030  if (c >= 'a' && c <= 'z') return c - 'a' + 26;
1031  if (c >= '0' && c <= '9') return c - '0' + 52;
1032  if (c == '+') return 62;
1033  if (c == '/') return 63;
1034  return 64;
1035 }
const GLubyte * c
Definition: glext.h:8905

Referenced by decode_base64().

◆ delete_header()

static BOOL delete_header ( request_t request,
DWORD  index 
)
static

Definition at line 395 of file request.c.

396 {
397  if (!request->num_headers) return FALSE;
398  if (index >= request->num_headers) return FALSE;
399  request->num_headers--;
400 
401  heap_free( request->headers[index].field );
402  heap_free( request->headers[index].value );
403 
404  memmove( &request->headers[index], &request->headers[index + 1], (request->num_headers - index) * sizeof(header_t) );
405  memset( &request->headers[request->num_headers], 0, sizeof(header_t) );
406  return TRUE;
407 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
GLuint index
Definition: glext.h:6031
Definition: tftpd.h:85
#define memset(x, y, z)
Definition: compat.h:39
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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

◆ dequeue_task()

static task_header_t* dequeue_task ( request_t request)
static

Definition at line 189 of file request.c.

190 {
191  task_header_t *task;
192 
193  EnterCriticalSection( &request->task_cs );
194  TRACE("%u tasks queued\n", list_count( &request->task_queue ));
195  task = LIST_ENTRY( list_head( &request->task_queue ), task_header_t, entry );
196  if (task) list_remove( &task->entry );
197  LeaveCriticalSection( &request->task_cs );
198 
199  TRACE("returning task %p\n", task);
200  return task;
201 }
uint8_t entry
Definition: isohybrid.c:63
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
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
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 1117 of file request.c.

1118 {
1119  if (!authinfo) return;
1120 
1121  if (SecIsValidHandle( &authinfo->ctx ))
1123  if (SecIsValidHandle( &authinfo->cred ))
1125 
1126  heap_free( authinfo->data );
1127  heap_free( authinfo );
1128 }
#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 ( request_t request,
BOOL  notify 
)
static

Definition at line 1885 of file request.c.

1886 {
1887  do
1888  {
1889  char *eol = memchr( request->read_buf + request->read_pos, '\n', request->read_size );
1890  if (eol)
1891  {
1892  remove_data( request, (eol + 1) - (request->read_buf + request->read_pos) );
1893  break;
1894  }
1895  request->read_pos = request->read_size = 0; /* discard everything */
1896  if (!read_more_data( request, -1, notify )) return FALSE;
1897  } while (request->read_size);
1898  return TRUE;
1899 }
#define TRUE
Definition: types.h:120
#define memchr(s, c, n)
Definition: mkisofs.h:875
static void remove_data(request_t *request, int count)
Definition: request.c:1851
int notify
Definition: msacm.c:1353
Definition: tftpd.h:85
static BOOL read_more_data(request_t *request, int maxlen, BOOL notify)
Definition: request.c:1858

Referenced by start_next_chunk().

◆ do_authorization()

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

Definition at line 1142 of file request.c.

1143 {
1144  struct authinfo *authinfo, **auth_ptr;
1145  enum auth_scheme scheme = scheme_from_flag( scheme_flag );
1146  const WCHAR *auth_target, *username, *password;
1147  WCHAR auth_value[2048], *auth_reply;
1148  DWORD len = sizeof(auth_value), len_scheme, flags;
1149  BOOL ret, has_auth_value;
1150 
1151  if (scheme == SCHEME_INVALID) return FALSE;
1152 
1153  switch (target)
1154  {
1156  has_auth_value = get_authvalue( request, WINHTTP_QUERY_WWW_AUTHENTICATE, scheme_flag, auth_value, len );
1157  auth_ptr = &request->authinfo;
1159  if (request->creds[TARGET_SERVER][scheme].username)
1160  {
1161  if (scheme != SCHEME_BASIC && !has_auth_value) return FALSE;
1162  username = request->creds[TARGET_SERVER][scheme].username;
1163  password = request->creds[TARGET_SERVER][scheme].password;
1164  }
1165  else
1166  {
1167  if (!has_auth_value) return FALSE;
1168  username = request->connect->username;
1169  password = request->connect->password;
1170  }
1171  break;
1172 
1174  if (!get_authvalue( request, WINHTTP_QUERY_PROXY_AUTHENTICATE, scheme_flag, auth_value, len ))
1175  return FALSE;
1176  auth_ptr = &request->proxy_authinfo;
1178  if (request->creds[TARGET_PROXY][scheme].username)
1179  {
1180  username = request->creds[TARGET_PROXY][scheme].username;
1181  password = request->creds[TARGET_PROXY][scheme].password;
1182  }
1183  else
1184  {
1185  username = request->connect->session->proxy_username;
1186  password = request->connect->session->proxy_password;
1187  }
1188  break;
1189 
1190  default:
1191  WARN("unknown target %x\n", target);
1192  return FALSE;
1193  }
1194  authinfo = *auth_ptr;
1195 
1196  switch (scheme)
1197  {
1198  case SCHEME_BASIC:
1199  {
1200  int userlen, passlen;
1201 
1202  if (!username || !password) return FALSE;
1203  if ((!authinfo && !(authinfo = alloc_authinfo())) || authinfo->finished) return FALSE;
1204 
1205  userlen = WideCharToMultiByte( CP_UTF8, 0, username, strlenW( username ), NULL, 0, NULL, NULL );
1206  passlen = WideCharToMultiByte( CP_UTF8, 0, password, strlenW( password ), NULL, 0, NULL, NULL );
1207 
1208  authinfo->data_len = userlen + 1 + passlen;
1209  if (!(authinfo->data = heap_alloc( authinfo->data_len ))) return FALSE;
1210 
1211  WideCharToMultiByte( CP_UTF8, 0, username, -1, authinfo->data, userlen, NULL, NULL );
1212  authinfo->data[userlen] = ':';
1213  WideCharToMultiByte( CP_UTF8, 0, password, -1, authinfo->data + userlen + 1, passlen, NULL, NULL );
1214 
1216  authinfo->finished = TRUE;
1217  break;
1218  }
1219  case SCHEME_NTLM:
1220  case SCHEME_NEGOTIATE:
1221  {
1223  SecBufferDesc out_desc, in_desc;
1224  SecBuffer out, in;
1226  const WCHAR *p;
1227  BOOL first = FALSE;
1228 
1229  if (!authinfo)
1230  {
1231  TimeStamp exp;
1233  WCHAR *domain, *user;
1234 
1235  if (!username || !password || !(authinfo = alloc_authinfo())) return FALSE;
1236 
1237  first = TRUE;
1238  domain = (WCHAR *)username;
1239  user = strchrW( username, '\\' );
1240 
1241  if (user) user++;
1242  else
1243  {
1244  user = (WCHAR *)username;
1245  domain = NULL;
1246  }
1248  id.User = user;
1249  id.UserLength = strlenW( user );
1250  id.Domain = domain;
1251  id.DomainLength = domain ? user - domain - 1 : 0;
1252  id.Password = (WCHAR *)password;
1253  id.PasswordLength = strlenW( password );
1254 
1257  &authinfo->cred, &exp );
1258  if (status == SEC_E_OK)
1259  {
1262  if (status == SEC_E_OK)
1263  {
1264  authinfo->max_token = info->cbMaxToken;
1266  }
1267  }
1268  if (status != SEC_E_OK)
1269  {
1270  WARN("AcquireCredentialsHandleW for scheme %s failed with error 0x%08x\n",
1272  heap_free( authinfo );
1273  return FALSE;
1274  }
1275  authinfo->scheme = scheme;
1276  }
1277  else if (authinfo->finished) return FALSE;
1278 
1279  if ((strlenW( auth_value ) < auth_schemes[authinfo->scheme].len ||
1280  strncmpiW( auth_value, auth_schemes[authinfo->scheme].str, auth_schemes[authinfo->scheme].len )))
1281  {
1282  ERR("authentication scheme changed from %s to %s\n",
1283  debugstr_w(auth_schemes[authinfo->scheme].str), debugstr_w(auth_value));
1285  *auth_ptr = NULL;
1286  return FALSE;
1287  }
1288  in.BufferType = SECBUFFER_TOKEN;
1289  in.cbBuffer = 0;
1290  in.pvBuffer = NULL;
1291 
1292  in_desc.ulVersion = 0;
1293  in_desc.cBuffers = 1;
1294  in_desc.pBuffers = &in;
1295 
1296  p = auth_value + auth_schemes[scheme].len;
1297  if (*p == ' ')
1298  {
1299  int len = strlenW( ++p );
1300  in.cbBuffer = decode_base64( p, len, NULL );
1301  if (!(in.pvBuffer = heap_alloc( in.cbBuffer ))) {
1303  *auth_ptr = NULL;
1304  return FALSE;
1305  }
1306  decode_base64( p, len, in.pvBuffer );
1307  }
1308  out.BufferType = SECBUFFER_TOKEN;
1309  out.cbBuffer = authinfo->max_token;
1310  if (!(out.pvBuffer = heap_alloc( authinfo->max_token )))
1311  {
1312  heap_free( in.pvBuffer );
1314  *auth_ptr = NULL;
1315  return FALSE;
1316  }
1317  out_desc.ulVersion = 0;
1318  out_desc.cBuffers = 1;
1319  out_desc.pBuffers = &out;
1320 
1322  first ? request->connect->servername : NULL, flags, 0,
1323  SECURITY_NETWORK_DREP, in.pvBuffer ? &in_desc : NULL, 0,
1324  &authinfo->ctx, &out_desc, &authinfo->attr, &authinfo->exp );
1325  heap_free( in.pvBuffer );
1326  if (status == SEC_E_OK)
1327  {
1328  heap_free( authinfo->data );
1329  authinfo->data = out.pvBuffer;
1330  authinfo->data_len = out.cbBuffer;
1331  authinfo->finished = TRUE;
1332  TRACE("sending last auth packet\n");
1333  }
1334  else if (status == SEC_I_CONTINUE_NEEDED)
1335  {
1336  heap_free( authinfo->data );
1337  authinfo->data = out.pvBuffer;
1338  authinfo->data_len = out.cbBuffer;
1339  TRACE("sending next auth packet\n");
1340  }
1341  else
1342  {
1343  ERR("InitializeSecurityContextW failed with error 0x%08x\n", status);
1344  heap_free( out.pvBuffer );
1346  *auth_ptr = NULL;
1347  return FALSE;
1348  }
1349  break;
1350  }
1351  default:
1352  ERR("invalid scheme %u\n", scheme);
1353  return FALSE;
1354  }
1355  *auth_ptr = authinfo;
1356 
1357  len_scheme = auth_schemes[authinfo->scheme].len;
1358  len = len_scheme + 1 + ((authinfo->data_len + 2) * 4) / 3;
1359  if (!(auth_reply = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
1360 
1361  memcpy( auth_reply, auth_schemes[authinfo->scheme].str, len_scheme * sizeof(WCHAR) );
1362  auth_reply[len_scheme] = ' ';
1363  encode_base64( authinfo->data, authinfo->data_len, auth_reply + len_scheme + 1 );
1364 
1366  ret = process_header( request, auth_target, auth_reply, flags, TRUE );
1367  heap_free( auth_reply );
1368  return ret;
1369 }
#define WINHTTP_QUERY_WWW_AUTHENTICATE
Definition: winhttp.h:338
#define TRUE
Definition: types.h:120
#define WINHTTP_QUERY_PROXY_AUTHENTICATE
Definition: winhttp.h:339
#define SECPKG_CRED_OUTBOUND
Definition: sspi.h:277
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WideCharToMultiByte
Definition: compat.h:101
SECURITY_STATUS WINAPI AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: wrapper.c:105
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:167
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
static const WCHAR attr_proxy_authorization[]
Definition: request.c:91
const GLint * first
Definition: glext.h:5794
#define WARN(fmt,...)
Definition: debug.h:111
#define WINHTTP_ADDREQ_FLAG_REPLACE
Definition: winhttp.h:88
#define ISC_REQ_DELEGATE
Definition: sspi.h:348
#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:986
struct _test_info info[]
Definition: SetCursorPos.c:19
CredHandle cred
#define CP_UTF8
Definition: nls.h:20
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
static BOOL get_authvalue(request_t *request, DWORD level, DWORD scheme, WCHAR *buffer, DWORD len)
Definition: request.c:1130
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:1037
LONG SECURITY_STATUS
Definition: sspi.h:34
static WCHAR username[]
Definition: url.c:32
static const struct @561 auth_schemes[]
#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:868
__wchar_t WCHAR
Definition: xmlstorage.h:180
void destroy_authinfo(struct authinfo *authinfo)
Definition: request.c:1117
#define SEC_WINNT_AUTH_IDENTITY_UNICODE
Definition: rpcdce.h:310
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int data_len
GLbitfield flags
Definition: glext.h:7161
int ret
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
#define SECBUFFER_TOKEN
Definition: sspi.h:147
#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:357
#define SECURITY_NETWORK_DREP
Definition: sspi.h:460
DWORD scheme
#define SEC_E_OK
Definition: winerror.h:2356
#define ISC_REQ_CONNECTION
Definition: sspi.h:359
#define ERR(fmt,...)
Definition: debug.h:109
char * data
GLuint in
Definition: glext.h:9616
DWORD exp
Definition: msg.c:15681
#define ISC_REQ_MUTUAL_AUTH
Definition: sspi.h:349
BOOL process_header(request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only)
Definition: request.c:409
DWORD scheme
Definition: request.c:870
Definition: tftpd.h:85
unsigned int ULONG
Definition: retypes.h:1
GLenum GLuint id
Definition: glext.h:5579
GLenum target
Definition: glext.h:7315
auth_scheme
static const WCHAR attr_authorization[]
Definition: request.c:60
static enum auth_scheme scheme_from_flag(DWORD flag)
Definition: request.c:882
#define WINHTTP_AUTH_TARGET_PROXY
Definition: winhttp.h:459
GLfloat GLfloat p
Definition: glext.h:8902
ULONG cBuffers
Definition: sspi.h:168
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:1099
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 ( request_t request)
static

Definition at line 2046 of file request.c.

2047 {
2048  DWORD size, bytes_read, bytes_total = 0, bytes_left = request->content_length - request->content_read;
2049  char buffer[2048];
2050 
2052  for (;;)
2053  {
2054  if (request->read_chunked) size = sizeof(buffer);
2055  else
2056  {
2057  if (bytes_total >= bytes_left) return;
2058  size = min( sizeof(buffer), bytes_left - bytes_total );
2059  }
2060  if (!read_data( request, buffer, size, &bytes_read, FALSE ) || !bytes_read) return;
2061  bytes_total += bytes_read;
2062  }
2063 }
static BOOL refill_buffer(request_t *request, BOOL notify)
Definition: request.c:1945
GLuint buffer
Definition: glext.h:5915
static BOOL read_data(request_t *request, void *buffer, DWORD size, DWORD *read, BOOL async)
Definition: request.c:2012
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

Referenced by send_request().

◆ encode_base64()

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

Definition at line 986 of file request.c.

987 {
988  UINT n = 0, x;
989  static const char base64enc[] =
990  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
991 
992  while (len > 0)
993  {
994  /* first 6 bits, all from bin[0] */
995  base64[n++] = base64enc[(bin[0] & 0xfc) >> 2];
996  x = (bin[0] & 3) << 4;
997 
998  /* next 6 bits, 2 from bin[0] and 4 from bin[1] */
999  if (len == 1)
1000  {
1001  base64[n++] = base64enc[x];
1002  base64[n++] = '=';
1003  base64[n++] = '=';
1004  break;
1005  }
1006  base64[n++] = base64enc[x | ((bin[1] & 0xf0) >> 4)];
1007  x = (bin[1] & 0x0f) << 2;
1008 
1009  /* next 6 bits 4 from bin[1] and 2 from bin[2] */
1010  if (len == 2)
1011  {
1012  base64[n++] = base64enc[x];
1013  base64[n++] = '=';
1014  break;
1015  }
1016  base64[n++] = base64enc[x | ((bin[2] & 0xc0) >> 6)];
1017 
1018  /* last 6 bits, all from bin [2] */
1019  base64[n++] = base64enc[bin[2] & 0x3f];
1020  bin += 3;
1021  len -= 3;
1022  }
1023  base64[n] = 0;
1024  return n;
1025 }
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 ( request_t request)
static

Definition at line 2004 of file request.c.

2005 {
2006  if (!request->content_length) return TRUE;
2007  if (request->read_chunked) return request->read_chunked_eof;
2008  if (request->content_length == ~0u) return FALSE;
2009  return (request->content_length == request->content_read);
2010 }
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
Definition: tftpd.h:85

Referenced by query_data_available(), and read_data().

◆ ensure_cred_handle()

static BOOL ensure_cred_handle ( session_t session)
static

Definition at line 1625 of file request.c.

1626 {
1629 
1630  if (session->cred_handle_initialized) return TRUE;
1631 
1632  memset( &cred, 0, sizeof(cred) );
1633  cred.dwVersion = SCHANNEL_CRED_VERSION;
1634  cred.grbitEnabledProtocols = map_secure_protocols( session->secure_protocols );
1636  NULL, NULL, &session->cred_handle, NULL )) != SEC_E_OK)
1637  {
1638  WARN( "AcquireCredentialsHandleW failed: 0x%08x\n", status );
1639  return FALSE;
1640  }
1641  session->cred_handle_initialized = TRUE;
1642  return TRUE;
1643 }
#define TRUE
Definition: types.h:120
#define SECPKG_CRED_OUTBOUND
Definition: sspi.h:277
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
#define WARN(fmt,...)
Definition: debug.h:111
BOOL cred_handle_initialized
static DWORD map_secure_protocols(DWORD mask)
Definition: request.c:1614
DWORD secure_protocols
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
CredHandle cred_handle
#define SEC_E_OK
Definition: winerror.h:2356
#define UNISP_NAME_W
Definition: sspi.h:38
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by open_connection().

◆ finished_reading()

static void finished_reading ( request_t request)
static

Definition at line 1969 of file request.c.

1970 {
1971  static const WCHAR closeW[] = {'c','l','o','s','e',0};
1972 
1973  BOOL close = FALSE;
1974  WCHAR connection[20];
1975  DWORD size = sizeof(connection);
1976 
1977  if (!request->netconn) return;
1978 
1979  if (request->hdr.disable_flags & WINHTTP_DISABLE_KEEP_ALIVE) close = TRUE;
1980  else if (query_headers( request, WINHTTP_QUERY_CONNECTION, NULL, connection, &size, NULL ) ||
1982  {
1983  if (!strcmpiW( connection, closeW )) close = TRUE;
1984  }
1985  else if (!strcmpW( request->version, http1_0 )) close = TRUE;
1986  if (close)
1987  {
1989  return;
1990  }
1991 
1992  cache_connection( request->netconn );
1993  request->netconn = NULL;
1994 }
#define TRUE
Definition: types.h:120
static void cache_connection(netconn_t *netconn)
Definition: request.c:1583
static const WCHAR http1_0[]
#define WINHTTP_QUERY_PROXY_CONNECTION
Definition: winhttp.h:367
#define WINHTTP_DISABLE_KEEP_ALIVE
Definition: winhttp.h:171
#define WINHTTP_QUERY_CONNECTION
Definition: winhttp.h:321
unsigned int BOOL
Definition: ntddk_ex.h:94
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:74
#define strcmpiW(s1, s2)
Definition: unicode.h:39
void close_connection(request_t *request)
Definition: request.c:1803
static BOOL query_headers(request_t *request, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:649
Definition: tftpd.h:85
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229

Referenced by read_data().

◆ free_header()

static void free_header ( header_t header)
static

Definition at line 277 of file request.c.

278 {
279  heap_free( header->field );
280  heap_free( header->value );
281  heap_free( header );
282 }
struct CFHEADER header
Definition: fdi.c:109
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 2997 of file request.c.

2998 {
2999  if (request->state < REQUEST_STATE_INITIALIZED) return;
3000  WinHttpCloseHandle( request->hrequest );
3001  WinHttpCloseHandle( request->hconnect );
3002  WinHttpCloseHandle( request->hsession );
3003  CloseHandle( request->thread );
3004  CloseHandle( request->wait );
3005  CloseHandle( request->cancel );
3006  heap_free( (WCHAR *)request->proxy.lpszProxy );
3007  heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
3008  heap_free( request->buffer );
3009  heap_free( request->verb );
3010  VariantClear( &request->data );
3011 }
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1153
__wchar_t WCHAR
Definition: xmlstorage.h:180
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
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 ( request_t request,
DWORD  level,
DWORD  scheme,
WCHAR buffer,
DWORD  len 
)
static

Definition at line 1130 of file request.c.

1131 {
1132  DWORD size, index = 0;
1133  for (;;)
1134  {
1135  size = len;
1136  if (!query_headers( request, level, NULL, buffer, &size, &index )) return FALSE;
1137  if (auth_scheme_from_header( buffer ) == scheme) break;
1138  }
1139  return TRUE;
1140 }
GLint level
Definition: gl.h:1546
#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
static BOOL query_headers(request_t *request, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:649
DWORD scheme
Definition: request.c:870
Definition: tftpd.h:85
unsigned int len
Definition: request.c:869
static DWORD auth_scheme_from_header(WCHAR *header)
Definition: request.c:890

Referenced by do_authorization().

◆ get_available_data()

static DWORD get_available_data ( request_t request)
static

Definition at line 1997 of file request.c.

1998 {
1999  if (request->read_chunked) return min( request->read_chunked_size, request->read_size );
2000  return request->read_size;
2001 }
#define min(a, b)
Definition: monoChain.cc:55
Definition: tftpd.h:85

Referenced by query_data_available(), and read_data().

◆ get_header_index()

static int get_header_index ( request_t request,
LPCWSTR  field,
int  requested_index,
BOOL  request_only 
)
static

Definition at line 356 of file request.c.

357 {
358  int index;
359 
360  TRACE("%s\n", debugstr_w(field));
361 
362  for (index = 0; index < request->num_headers; index++)
363  {
364  if (strcmpiW( request->headers[index].field, field )) continue;
365  if (request_only && !request->headers[index].is_request) continue;
366  if (!request_only && request->headers[index].is_request) continue;
367 
368  if (!requested_index) break;
369  requested_index--;
370  }
371  if (index >= request->num_headers) index = -1;
372  TRACE("returning %d\n", index);
373  return index;
374 }
#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
#define strcmpiW(s1, s2)
Definition: unicode.h:39
Definition: tftpd.h:85

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

◆ get_redirect_url()

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

Definition at line 2502 of file request.c.

2503 {
2504  DWORD size;
2505  WCHAR *ret;
2506 
2509  if (!(ret = heap_alloc( size ))) return NULL;
2510  *len = size / sizeof(WCHAR);
2512  heap_free( ret );
2513  return NULL;
2514 }
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
DWORD get_last_error(void)
Definition: session.c:65
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
static BOOL query_headers(request_t *request, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:649
Definition: tftpd.h:85
#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 3082 of file request.c.

3083 {
3084  HRESULT hr;
3085 
3086  if (!winhttp_typelib)
3087  {
3088  ITypeLib *typelib;
3089 
3090  hr = LoadRegTypeLib( &LIBID_WinHttp, 5, 1, LOCALE_SYSTEM_DEFAULT, &typelib );
3091  if (FAILED(hr))
3092  {
3093  ERR("LoadRegTypeLib failed: %08x\n", hr);
3094  return hr;
3095  }
3097  ITypeLib_Release( typelib );
3098  }
3099  if (!winhttp_typeinfo[tid])
3100  {
3102 
3103  hr = ITypeLib_GetTypeInfoOfGuid( winhttp_typelib, winhttp_tid_id[tid], &typeinfo );
3104  if (FAILED(hr))
3105  {
3106  ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(winhttp_tid_id[tid]), hr);
3107  return hr;
3108  }
3110  ITypeInfo_Release( typeinfo );
3111  }
3112  *ret = winhttp_typeinfo[tid];
3113  ITypeInfo_AddRef(winhttp_typeinfo[tid]);
3114  return S_OK;
3115 }
static REFIID winhttp_tid_id[]
Definition: request.c:3077
HRESULT hr
Definition: shlfolder.c:183
static ITypeLib * typelib
Definition: apps.c:105
static ITypeLib * winhttp_typelib
Definition: request.c:3074
#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:3075
LONG HRESULT
Definition: typedefs.h:77
#define LOCALE_SYSTEM_DEFAULT
int ret
static ITypeInfo * typeinfo[last_tid]
Definition: apps.c:106
#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:534
static TfClientId tid

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

◆ handle_authorization()

static BOOL handle_authorization ( request_t request,
DWORD  status 
)
static

Definition at line 2287 of file request.c.

2288 {
2289  DWORD i, schemes, first, level, target;
2290 
2291  switch (status)
2292  {
2293  case HTTP_STATUS_DENIED:
2296  break;
2297 
2301  break;
2302 
2303  default:
2304  WARN("unhandled status %u\n", status);
2305  return FALSE;
2306  }
2307 
2308  if (!query_auth_schemes( request, level, &schemes, &first )) return FALSE;
2309  if (do_authorization( request, target, first )) return TRUE;
2310 
2311  schemes &= ~first;
2312  for (i = 0; i < num_auth_schemes; i++)
2313  {
2314  if (!(schemes & auth_schemes[i].scheme)) continue;
2316  }
2317  return FALSE;
2318 }
#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
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
static BOOL query_auth_schemes(request_t *request, DWORD level, LPDWORD supported, LPDWORD first)
Definition: request.c:902
static const struct @561 auth_schemes[]
static BOOL do_authorization(request_t *request, DWORD target, DWORD scheme_flag)
Definition: request.c:1142
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_PROXY_AUTH_REQ
Definition: winhttp.h:262
DWORD scheme
Definition: request.c:870
Definition: tftpd.h:85
static const unsigned int num_auth_schemes
Definition: request.c:880
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_redirect()

static BOOL handle_redirect ( request_t request,
DWORD  status 
)
static

Definition at line 2516 of file request.c.

2517 {
2518  BOOL ret = FALSE;
2519  DWORD len, len_url;
2520  URL_COMPONENTS uc;
2521  connect_t *connect = request->connect;
2523  WCHAR *hostname = NULL, *location;
2524  int index;
2525 
2526  if (!(location = get_redirect_url( request, &len_url ))) return FALSE;
2527 
2528  memset( &uc, 0, sizeof(uc) );
2529  uc.dwStructSize = sizeof(uc);
2531 
2532  if (!WinHttpCrackUrl( location, len_url, 0, &uc )) /* assume relative redirect */
2533  {
2534  WCHAR *path, *p;
2535 
2536  if (location[0] == '/')
2537  {
2538  len = strlenW( location );
2539  if (!(path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end;
2540  strcpyW( path, location );
2541  }
2542  else
2543  {
2544  if ((p = strrchrW( request->path, '/' ))) *p = 0;
2545  len = strlenW( request->path ) + 1 + strlenW( location );
2546  if (!(path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end;
2547  strcpyW( path, request->path );
2548  strcatW( path, slashW );
2549  strcatW( path, location );
2550  }
2551  heap_free( request->path );
2552  request->path = path;
2553 
2555  }
2556  else
2557  {
2558  if (uc.nScheme == INTERNET_SCHEME_HTTP && request->hdr.flags & WINHTTP_FLAG_SECURE)
2559  {
2560  if (request->hdr.redirect_policy == WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP) goto end;
2561  TRACE("redirect from secure page to non-secure page\n");
2562  request->hdr.flags &= ~WINHTTP_FLAG_SECURE;
2563  }
2564  else if (uc.nScheme == INTERNET_SCHEME_HTTPS && !(request->hdr.flags & WINHTTP_FLAG_SECURE))
2565  {
2566  TRACE("redirect from non-secure page to secure page\n");
2567  request->hdr.flags |= WINHTTP_FLAG_SECURE;
2568  }
2569 
2571 
2572  len = uc.dwHostNameLength;
2573  if (!(hostname = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end;
2574  memcpy( hostname, uc.lpszHostName, len * sizeof(WCHAR) );
2575  hostname[len] = 0;
2576 
2577  port = uc.nPort ? uc.nPort : (uc.nScheme == INTERNET_SCHEME_HTTPS ? 443 : 80);
2578  if (strcmpiW( connect->hostname, hostname ) || connect->serverport != port)
2579  {
2580  heap_free( connect->hostname );
2581  connect->hostname = hostname;
2582  connect->hostport = port;
2583  if (!(ret = set_server_for_hostname( connect, hostname, port ))) goto end;
2584 
2585  netconn_close( request->netconn );
2586  request->netconn = NULL;
2587  request->content_length = request->content_read = 0;
2588  request->read_pos = request->read_size = 0;
2589  request->read_chunked = request->read_chunked_eof = FALSE;
2590  }
2591  else heap_free( hostname );
2592 
2594  if (!(ret = open_connection( request ))) goto end;
2595 
2596  heap_free( request->path );
2597  request->path = NULL;
2598  if (uc.dwUrlPathLength)
2599  {
2601  if (!(request->path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end;
2602  strcpyW( request->path, uc.lpszUrlPath );
2603  }
2604  else request->path = strdupW( slashW );
2605  }
2606 
2607  /* remove content-type/length headers */
2610 
2612  {
2613  heap_free( request->verb );
2614  request->verb = strdupW( getW );
2615  request->optional = NULL;
2616  request->optional_len = 0;
2617  }
2618  ret = TRUE;
2619 
2620 end:
2621  heap_free( location );
2622  return ret;
2623 }
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
#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
GLsizei const GLchar ** path
Definition: glext.h:7234
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
DWORD dwUrlPathLength
Definition: winhttp.h:477
static BOOL add_host_header(request_t *request, DWORD modifier)
Definition: request.c:1813
#define WINHTTP_ADDREQ_FLAG_REPLACE
Definition: winhttp.h:88
GLuint GLuint end
Definition: gl.h:1545
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
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 BOOL delete_header(request_t *request, DWORD index)
Definition: request.c:395
static BOOL open_connection(request_t *request)
Definition: request.c:1645
void send_callback(object_header_t *hdr, DWORD status, LPVOID info, DWORD buflen)
Definition: session.c:71
DWORD dwSchemeLength
Definition: winhttp.h:467
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL set_server_for_hostname(connect_t *connect, LPCWSTR server, INTERNET_PORT port)
Definition: session.c:459
static const WCHAR attr_content_type[]
Definition: request.c:72
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:67
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
BOOL WINAPI WinHttpCrackUrl(LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONENTSW uc)
Definition: url.c:183
#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
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
LPWSTR lpszHostName
Definition: winhttp.h:469
#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
Definition: services.c:325
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
Definition: tftpd.h:85
static int get_header_index(request_t *request, LPCWSTR field, int requested_index, BOOL request_only)
Definition: request.c:356
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
GLfloat GLfloat p
Definition: glext.h:8902
static const WCHAR getW[]
Definition: lex.c:55
unsigned int len
Definition: request.c:869
USHORT port
Definition: uri.c:227
#define memset(x, y, z)
Definition: compat.h:39
BOOL netconn_close(netconn_t *conn)
Definition: net.c:405
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static WCHAR * get_redirect_url(request_t *request, DWORD *len)
Definition: request.c:2502
Definition: ps.c:97
static const WCHAR slashW[]
Definition: devenum.c:62

Referenced by receive_response().

◆ impl_from_IStream()

static struct stream* impl_from_IStream ( IStream iface)
inlinestatic

Definition at line 4083 of file request.c.

4084 {
4085  return CONTAINING_RECORD( iface, struct stream, IStream_iface );
4086 }
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 3328 of file request.c.

3329 {
3330  request->hrequest = NULL;
3331  request->hconnect = NULL;
3332  request->hsession = NULL;
3333  request->thread = NULL;
3334  request->wait = NULL;
3335  request->cancel = NULL;
3336  request->buffer = NULL;
3337  request->verb = NULL;
3338  request->offset = 0;
3339  request->bytes_available = 0;
3340  request->bytes_read = 0;
3341  request->error = ERROR_SUCCESS;
3342  request->async = FALSE;
3344  request->disable_feature = 0;
3345  request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_DEFAULT_PROXY;
3346  request->proxy.lpszProxy = NULL;
3347  request->proxy.lpszProxyBypass = NULL;
3348  request->resolve_timeout = 0;
3349  request->connect_timeout = 60000;
3350  request->send_timeout = 30000;
3351  request->receive_timeout = 30000;
3352  request->url_codepage = CP_UTF8;
3353  VariantInit( &request->data );
3355 }
#define ERROR_SUCCESS
Definition: deptool.c:10
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
#define CP_UTF8
Definition: nls.h:20
#define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
Definition: winhttp.h:62
smooth NULL
Definition: ftsmooth.c:416
#define WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM
Definition: winhttp.h:152
Definition: tftpd.h:85

Referenced by winhttp_request_Open().

◆ insert_header()

static BOOL insert_header ( request_t request,
header_t header 
)
static

Definition at line 376 of file request.c.

377 {
378  DWORD count = request->num_headers + 1;
379  header_t *hdrs;
380 
381  if (request->headers)
382  hdrs = heap_realloc_zero( request->headers, sizeof(header_t) * count );
383  else
384  hdrs = heap_alloc_zero( sizeof(header_t) );
385  if (!hdrs) return FALSE;
386 
387  request->headers = hdrs;
388  request->headers[count - 1].field = strdupW( header->field );
389  request->headers[count - 1].value = strdupW( header->value );
390  request->headers[count - 1].is_request = header->is_request;
391  request->num_headers = count;
392  return TRUE;
393 }
#define TRUE
Definition: types.h:120
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: tftpd.h:85
struct CFHEADER header
Definition: fdi.c:109

Referenced by process_header().

◆ map_secure_protocols()

static DWORD map_secure_protocols ( DWORD  mask)
static

Definition at line 1614 of file request.c.

1615 {
1616  DWORD ret = 0;
1622  return ret;
1623 }
#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().

◆ open_connection()

static BOOL open_connection ( request_t request)
static

Definition at line 1645 of file request.c.

1646 {
1647  BOOL is_secure = request->hdr.flags & WINHTTP_FLAG_SECURE;
1648  hostdata_t *host = NULL, *iter;
1649  netconn_t *netconn = NULL;
1650  connect_t *connect;
1651  WCHAR *addressW = NULL;
1653  DWORD len;
1654 
1655  if (request->netconn) goto done;
1656 
1657  connect = request->connect;
1658  port = connect->serverport ? connect->serverport : (request->hdr.flags & WINHTTP_FLAG_SECURE ? 443 : 80);
1659 
1661 
1663  {
1664  if (iter->port == port && !strcmpW( connect->servername, iter->hostname ) && !is_secure == !iter->secure)
1665  {
1666  host = iter;
1667  host->ref++;
1668  break;
1669  }
1670  }
1671 
1672  if (!host)
1673  {
1674  if ((host = heap_alloc( sizeof(*host) )))
1675  {
1676  host->ref = 1;
1677  host->secure = is_secure;
1678  host->port = port;
1679  list_init( &host->connections );
1680  if ((host->hostname = strdupW( connect->servername )))
1681  {
1682  list_add_head( &connection_pool, &host->entry );
1683  }
1684  else
1685  {
1686  heap_free( host );
1687  host = NULL;
1688  }
1689  }
1690  }
1691 
1693 
1694  if (!host) return FALSE;
1695 
1696  for (;;)
1697  {
1699  if (!list_empty( &host->connections ))
1700  {
1701  netconn = LIST_ENTRY( list_head( &host->connections ), netconn_t, entry );
1702  list_remove( &netconn->entry );
1703  }
1705  if (!netconn) break;
1706 
1707  if (netconn_is_alive( netconn )) break;
1708  TRACE("connection %p no longer alive, closing\n", netconn);
1709  netconn_close( netconn );
1710  netconn = NULL;
1711  }
1712 
1713  if (!connect->resolved && netconn)
1714  {
1715  connect->sockaddr = netconn->sockaddr;
1716  connect->resolved = TRUE;
1717  }
1718 
1719  if (!connect->resolved)
1720  {
1721  len = strlenW( host->hostname ) + 1;
1723 
1724  if (!netconn_resolve( host->hostname, port, &connect->sockaddr, request->resolve_timeout ))
1725  {
1726  release_host( host );
1727  return FALSE;
1728  }
1729  connect->resolved = TRUE;
1730 
1731  if (!(addressW = addr_to_str( &connect->sockaddr )))
1732  {
1733  release_host( host );
1734  return FALSE;
1735  }
1736  len = strlenW( addressW ) + 1;
1738  }
1739 
1740  if (!netconn)
1741  {
1742  if (!addressW && !(addressW = addr_to_str( &connect->sockaddr )))
1743  {
1744  release_host( host );
1745  return FALSE;
1746  }
1747 
1748  TRACE("connecting to %s:%u\n", debugstr_w(addressW), port);
1749 
1751 
1752  if (!(netconn = netconn_create( host, &connect->sockaddr, request->connect_timeout )))
1753  {
1754  heap_free( addressW );
1755  release_host( host );
1756  return FALSE;
1757  }
1758  netconn_set_timeout( netconn, TRUE, request->send_timeout );
1759  netconn_set_timeout( netconn, FALSE, request->recv_timeout );
1760  if (is_secure)
1761  {
1762  if (connect->session->proxy_server &&
1763  strcmpiW( connect->hostname, connect->servername ))
1764  {
1765  if (!secure_proxy_connect( request ))
1766  {
1767  heap_free( addressW );
1768  netconn_close( netconn );
1769  return FALSE;
1770  }
1771  }
1772  if (!ensure_cred_handle( connect->session ) ||
1773  !netconn_secure_connect( netconn, connect->hostname, request->security_flags,
1774  &connect->session->cred_handle ))
1775  {
1776  heap_free( addressW );
1777  netconn_close( netconn );
1778  return FALSE;
1779  }
1780  }
1781 
1782  request->netconn = netconn;
1783  send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, addressW, strlenW(addressW) + 1 );
1784  }
1785  else
1786  {
1787  TRACE("using connection %p\n", netconn);
1788 
1789  netconn_set_timeout( netconn, TRUE, request->send_timeout );
1790  netconn_set_timeout( netconn, FALSE, request->recv_timeout );
1791  request->netconn = netconn;
1792  }
1793 
1794 done:
1795  request->read_pos = request->read_size = 0;
1796  request->read_chunked = FALSE;
1797  request->read_chunked_size = ~0u;
1798  request->read_chunked_eof = FALSE;
1799  heap_free( addressW );
1800  return TRUE;
1801 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
BOOL netconn_is_alive(netconn_t *netconn)
Definition: net.c:784
BOOL netconn_secure_connect(netconn_t *conn, WCHAR *hostname, DWORD security_flags, CredHandle *cred_handle)
Definition: net.c:427
#define TRUE
Definition: types.h:120
#define WINHTTP_CALLBACK_STATUS_RESOLVING_NAME
Definition: winhttp.h:380
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER
Definition: winhttp.h:382
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
uint8_t entry
Definition: isohybrid.c:63
char * host
Definition: whois.c:55
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
netconn_t * netconn_create(hostdata_t *host, const struct sockaddr_storage *sockaddr, int timeout)
Definition: net.c:300
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER
Definition: winhttp.h:383
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static CRITICAL_SECTION connection_pool_cs
Definition: request.c:1515
struct sockaddr_storage sockaddr
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
WORD INTERNET_PORT
Definition: winhttp.h:38
void send_callback(object_header_t *hdr, DWORD status, LPVOID info, DWORD buflen)
Definition: session.c:71
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
void release_host(hostdata_t *host)
Definition: request.c:1526
static struct list connection_pool
Definition: request.c:1524
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
static BOOL is_secure(RpcConnection_http *httpc)
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
static BOOL ensure_cred_handle(session_t *session)
Definition: request.c:1625
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL netconn_resolve(WCHAR *hostname, INTERNET_PORT port, struct sockaddr_storage *sa, int timeout)
Definition: net.c:896
unsigned long DWORD
Definition: ntddk_ex.h:95
static WCHAR * addr_to_str(struct sockaddr_storage *addr)
Definition: request.c:1494
GLenum GLsizei len
Definition: glext.h:6722
static BOOL secure_proxy_connect(request_t *request)
Definition: request.c:1454
#define strcmpiW(s1, s2)
Definition: unicode.h:39
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
DWORD netconn_set_timeout(netconn_t *netconn, BOOL send, int value)
Definition: net.c:768
Definition: tftpd.h:85
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
#define WINHTTP_CALLBACK_STATUS_NAME_RESOLVED
Definition: winhttp.h:381
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define LIST_ENTRY(type)
Definition: queue.h:175
unsigned int len
Definition: request.c:869
USHORT port
Definition: uri.c:227
BOOL netconn_close(netconn_t *conn)
Definition: net.c:405
struct list entry
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by handle_redirect(), and send_request().

◆ parse_header()

static header_t* parse_header ( LPCWSTR  string)
static

Definition at line 305 of file request.c.

306 {
307  const WCHAR *p, *q;
308  header_t *header;
309  int len;
310 
311  p = string;
312  if (!(q = strchrW( p, ':' )))
313  {
314  WARN("no ':' in line %s\n", debugstr_w(string));
315  return NULL;
316  }
317  if (q == string)
318  {
319  WARN("empty field name in line %s\n", debugstr_w(string));
320  return NULL;
321  }
322  while (*p != ':')
323  {
324  if (!valid_token_char( *p ))
325  {
326  WARN("invalid character in field name %s\n", debugstr_w(string));
327  return NULL;
328  }
329  p++;
330  }
331  len = q - string;
332  if (!(header = heap_alloc_zero( sizeof(header_t) ))) return NULL;
333  if (!(header->field = heap_alloc( (len + 1) * sizeof(WCHAR) )))
334  {
335  heap_free( header );
336  return NULL;
337  }
338  memcpy( header->field, string, len * sizeof(WCHAR) );
339  header->field[len] = 0;
340 
341  q++; /* skip past colon */
342  while (*q == ' ') q++;
343  len = strlenW( q );
344 
345  if (!(header->value = heap_alloc( (len + 1) * sizeof(WCHAR) )))
346  {
347  free_header( header );
348  return NULL;
349  }
350  memcpy( header->value, q, len * sizeof(WCHAR) );
351  header->value[len] = 0;
352 
353  return header;
354 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define WARN(fmt,...)
Definition: debug.h:111
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
static BOOL valid_token_char(WCHAR c)
Definition: request.c:284
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
char string[160]
Definition: util.h:11
static void free_header(header_t *header)
Definition: request.c:277
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int len
Definition: request.c:869
struct CFHEADER header
Definition: fdi.c:109
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by add_request_headers(), and read_reply().

◆ process_header()

BOOL process_header ( request_t request,
LPCWSTR  field,
LPCWSTR  value,
DWORD  flags,
BOOL  request_only 
)

Definition at line 409 of file request.c.

410 {
411  int index;
412  header_t hdr;
413 
414  TRACE("%s: %s 0x%08x\n", debugstr_w(field), debugstr_w(value), flags);
415 
416  if ((index = get_header_index( request, field, 0, request_only )) >= 0)
417  {
419  }
420 
422  {
423  if (index >= 0)
424  {
426  if (!value || !value[0]) return TRUE;
427  }
428  else if (!(flags & WINHTTP_ADDREQ_FLAG_ADD))
429  {
431  return FALSE;
432  }
433 
434  hdr.field = (LPWSTR)field;
435  hdr.value = (LPWSTR)value;
436  hdr.is_request = request_only;
437  return insert_header( request, &hdr );
438  }
439  else if (value)
440  {
441 
443  index >= 0)
444  {
445  WCHAR *tmp;
446  int len, len_orig, len_value;
447  header_t *header = &request->headers[index];
448 
449  len_orig = strlenW( header->value );
450  len_value = strlenW( value );
451 
452  len = len_orig + len_value + 2;
453  if (!(tmp = heap_realloc( header->value, (len + 1) * sizeof(WCHAR) ))) return FALSE;
454  header->value = tmp;
455  header->value[len_orig++] = (flags & WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA) ? ',' : ';';
456  header->value[len_orig++] = ' ';
457 
458  memcpy( &header->value[len_orig], value, len_value * sizeof(WCHAR) );
459  header->value[len] = 0;
460  return TRUE;
461  }
462  else
463  {
464  hdr.field = (LPWSTR)field;
465  hdr.value = (LPWSTR)value;
466  hdr.is_request = request_only;
467  return insert_header( request, &hdr );
468  }
469  }
470 
471  return TRUE;
472 }
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
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
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Definition: winhttp.h:85
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static BOOL delete_header(request_t *request, DWORD index)
Definition: request.c:395
#define debugstr_w
Definition: kernel32.h:32
GLuint index
Definition: glext.h:6031
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
Definition: winhttp.h:86
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
#define WINHTTP_ADDREQ_FLAG_ADD_IF_NEW
Definition: winhttp.h:83
GLbitfield flags
Definition: glext.h:7161
#define index(s, c)
Definition: various.h:29
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
static BOOL insert_header(request_t *request, header_t *header)
Definition: request.c:376
Definition: tftpd.h:85
static int get_header_index(request_t *request, LPCWSTR field, int requested_index, BOOL request_only)
Definition: request.c:356
void set_last_error(DWORD error)
Definition: session.c:59
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned int len
Definition: request.c:869
#define ERROR_WINHTTP_HEADER_NOT_FOUND
Definition: winhttp.h:213
struct CFHEADER header
Definition: fdi.c:109

Referenced by add_host_header(), add_request_headers(), do_authorization(), read_reply(), send_request(), and store_accept_types().

◆ query_auth_schemes()

static BOOL query_auth_schemes ( request_t request,
DWORD  level,
LPDWORD  supported,
LPDWORD  first 
)
static

Definition at line 902 of file request.c.

903 {
904  DWORD index = 0, supported_schemes = 0, first_scheme = 0;
905  BOOL ret = FALSE;
906 
907  for (;;)
908  {
909  WCHAR *buffer;
910  DWORD size, scheme;
911 
912  size = 0;
915 
916  index--;
917  if (!(buffer = heap_alloc( size ))) return FALSE;
919  {
920  heap_free( buffer );
921  return FALSE;
922  }
924  heap_free( buffer );
925  if (!scheme) continue;
926 
927  if (!first_scheme) first_scheme = scheme;
928  supported_schemes |= scheme;
929 
930  ret = TRUE;
931  }
932 
933  if (ret)
934  {
935  *supported = supported_schemes;
936  *first = first_scheme;
937  }
938  return ret;
939 }
GLint level
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
const GLint * first
Definition: glext.h:5794
GLuint buffer
Definition: glext.h:5915
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD get_last_error(void)
Definition: session.c:65
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static BOOL query_headers(request_t *request, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:649
DWORD scheme
Definition: request.c:870
Definition: tftpd.h:85
static DWORD auth_scheme_from_header(WCHAR *header)
Definition: request.c:890
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by handle_authorization(), and WinHttpQueryAuthSchemes().

◆ query_data_available()

static BOOL query_data_available ( request_t request,
DWORD available,
BOOL  async 
)
static

Definition at line 2730 of file request.c.

2731 {
2732  DWORD count = 0;
2733 
2734  if (end_of_read_data( request )) goto done;
2735 
2737  if (!request->read_chunked && request->netconn)
2739  if (!count)
2740  {
2741  refill_buffer( request, async );
2743  if (!request->read_chunked && request->netconn)
2745  }
2746 
2747 done:
2749  TRACE("%u bytes available\n", count);
2750  if (available) *available = count;
2751  return TRUE;
2752 }
#define TRUE
Definition: types.h:120
static BOOL refill_buffer(request_t *request, BOOL notify)
Definition: request.c:1945
GLuint GLuint GLsizei count
Definition: gl.h:1545
static BOOL end_of_read_data(request_t *request)
Definition: request.c:2004
void send_callback(object_header_t *hdr, DWORD status, LPVOID info, DWORD buflen)
Definition: session.c:71
static WCHAR available[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2336
#define TRACE(s)
Definition: solgame.cpp:4
#define WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE
Definition: winhttp.h:397
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD get_available_data(request_t *request)
Definition: request.c:1997
Definition: tftpd.h:85
ULONG netconn_query_data_available(netconn_t *conn)
Definition: net.c:763

Referenced by task_query_data_available(), and WinHttpQueryDataAvailable().

◆ query_headers()

static BOOL query_headers ( request_t request,
DWORD  level,
LPCWSTR  name,
LPVOID  buffer,
LPDWORD  buflen,
LPDWORD  index 
)
static

Definition at line 649 of file request.c.

650 {
651  header_t *header = NULL;
652  BOOL request_only, ret = FALSE;
653  int requested_index, header_index = -1;
654  DWORD attr, len;
655 
656  request_only = level & WINHTTP_QUERY_FLAG_REQUEST_HEADERS;
657  requested_index = index ? *index : 0;
658 
660  switch (attr)
661  {
663  {
664  header_index = get_header_index( request, name, requested_index, request_only );
665  break;
666  }
668  {
669  WCHAR *headers, *p, *q;
670 
671  if (request_only)
673  else
674  headers = request->raw_headers;
675 
676  if (!(p = headers)) return FALSE;
677  for (len = 0; *p; p++) if (*p != '\r') len++;
678 
679  if (!buffer || len * sizeof(WCHAR) > *buflen)
681  else
682  {
683  for (p = headers, q = buffer; *p; p++, q++)
684  {
685  if (*p != '\r') *q = *p;
686  else
687  {
688  *q = 0;
689  p++; /* skip '\n' */
690  }
691  }
692  TRACE("returning data: %s\n", debugstr_wn(buffer, len));
693  if (len) len--;
694  ret = TRUE;
695  }
696  *buflen = len * sizeof(WCHAR);
697  if (request_only) heap_free( headers );
698  return ret;
699  }
701  {
702  WCHAR *headers;
703 
704  if (request_only)
706  else
707  headers = request->raw_headers;
708 
709  if (!headers) return FALSE;
710  len = strlenW( headers ) * sizeof(WCHAR);
711  if (!buffer || len + sizeof(WCHAR) > *buflen)
712  {
713  len += sizeof(WCHAR);
715  }
716  else
717  {
718  memcpy( buffer, headers, len + sizeof(WCHAR) );
719  TRACE("returning data: %s\n", debugstr_wn(buffer, len / sizeof(WCHAR)));
720  ret = TRUE;
721  }
722  *buflen = len;
723  if (request_only) heap_free( headers );
724  return ret;
725  }
727  len = strlenW( request->version ) * sizeof(WCHAR);
728  if (!buffer || len + sizeof(WCHAR) > *buflen)
729  {
730  len += sizeof(WCHAR);
732  }
733  else
734  {
735  strcpyW( buffer, request->version );
736  TRACE("returning string: %s\n", debugstr_w(buffer));
737  ret = TRUE;
738  }
739  *buflen = len;
740  return ret;
741 
743  len = strlenW( request->status_text ) * sizeof(WCHAR);
744  if (!buffer || len + sizeof(WCHAR) > *buflen)
745  {
746  len += sizeof(WCHAR);
748  }
749  else
750  {
751  strcpyW( buffer, request->status_text );
752  TRACE("returning string: %s\n", debugstr_w(buffer));
753  ret = TRUE;
754  }
755  *buflen = len;
756  return ret;
757 
758  default:
759  if (attr >= sizeof(attribute_table)/sizeof(attribute_table[0]) || !attribute_table[attr])
760  {
761  FIXME("attribute %u not implemented\n", attr);
762  return FALSE;
763  }
764  TRACE("attribute %s\n", debugstr_w(attribute_table[attr]));
765  header_index = get_header_index( request, attribute_table[attr], requested_index, request_only );
766  break;
767  }
768 
769  if (header_index >= 0)
770  {
771  header = &request->headers[header_index];
772  }
773  if (!header || (request_only && !header->is_request))
774  {
776  return FALSE;
777  }
778  if (index) *index += 1;
780  {
781  if (!buffer || sizeof(int) > *buflen)
782  {
784  }
785  else
786  {
787  int *number = buffer;
788  *number = atoiW( header->value );
789  TRACE("returning number: %d\n", *number);
790  ret = TRUE;
791  }
792  *buflen = sizeof(int);
793  }
795  {
796  SYSTEMTIME *st = buffer;
797  if (!buffer || sizeof(SYSTEMTIME) > *buflen)
798  {
800  }
801  else if ((ret = WinHttpTimeToSystemTime( header->value, st )))
802  {
803  TRACE("returning time: %04d/%02d/%02d - %d - %02d:%02d:%02d.%02d\n",
804  st->wYear, st->wMonth, st->wDay, st->wDayOfWeek,
805  st->wHour, st->wMinute, st->wSecond, st->wMilliseconds);
806  }
807  *buflen = sizeof(SYSTEMTIME);
808  }
809  else if (header->value)
810  {
811  len = strlenW( header->value ) * sizeof(WCHAR);
812  if (!buffer || len + sizeof(WCHAR) > *buflen)
813  {
814  len += sizeof(WCHAR);
816  }
817  else
818  {
819  strcpyW( buffer, header->value );
820  TRACE("returning string: %s\n", debugstr_w(buffer));
821  ret = TRUE;
822  }
823  *buflen =