ReactOS 0.4.15-dev-7842-g558ab78
winhttp_private.h File Reference
#include "wine/heap.h"
#include "wine/list.h"
#include "wine/unicode.h"
#include "ole2.h"
#include "sspi.h"
#include "wincrypt.h"
Include dependency graph for winhttp_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  object_vtbl
 
struct  object_header
 
struct  hostdata
 
struct  session
 
struct  connect
 
struct  netconn
 
struct  header
 
struct  authinfo
 
struct  request
 
struct  task_header
 
struct  send_request
 
struct  receive_response
 
struct  query_data
 
struct  read_data
 
struct  write_data
 

Enumerations

enum  auth_target { TARGET_INVALID = -1 , TARGET_SERVER , TARGET_PROXY , TARGET_MAX }
 
enum  auth_scheme {
  SCHEME_INVALID = -1 , SCHEME_BASIC , SCHEME_NTLM , SCHEME_PASSPORT ,
  SCHEME_DIGEST , SCHEME_NEGOTIATE , SCHEME_MAX
}
 

Functions

struct object_headeraddref_object (struct object_header *) DECLSPEC_HIDDEN
 
struct object_headergrab_object (HINTERNET) DECLSPEC_HIDDEN
 
void release_object (struct object_header *) DECLSPEC_HIDDEN
 
HINTERNET alloc_handle (struct object_header *) DECLSPEC_HIDDEN
 
BOOL free_handle (HINTERNET) DECLSPEC_HIDDEN
 
void send_callback (struct object_header *, DWORD, LPVOID, DWORD) DECLSPEC_HIDDEN
 
void close_connection (struct request *) DECLSPEC_HIDDEN
 
void netconn_close (struct netconn *) DECLSPEC_HIDDEN
 
struct netconnnetconn_create (struct hostdata *, const struct sockaddr_storage *, int) DECLSPEC_HIDDEN
 
void netconn_unload (void) DECLSPEC_HIDDEN
 
ULONG netconn_query_data_available (struct netconn *) DECLSPEC_HIDDEN
 
BOOL netconn_recv (struct netconn *, void *, size_t, int, int *) DECLSPEC_HIDDEN
 
BOOL netconn_resolve (WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int) DECLSPEC_HIDDEN
 
BOOL netconn_secure_connect (struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL) DECLSPEC_HIDDEN
 
BOOL netconn_send (struct netconn *, const void *, size_t, int *) DECLSPEC_HIDDEN
 
DWORD netconn_set_timeout (struct netconn *, BOOL, int) DECLSPEC_HIDDEN
 
BOOL netconn_is_alive (struct netconn *) DECLSPEC_HIDDEN
 
const voidnetconn_get_certificate (struct netconn *) DECLSPEC_HIDDEN
 
int netconn_get_cipher_strength (struct netconn *) DECLSPEC_HIDDEN
 
BOOL set_cookies (struct request *, const WCHAR *) DECLSPEC_HIDDEN
 
BOOL add_cookie_headers (struct request *) DECLSPEC_HIDDEN
 
BOOL add_request_headers (struct request *, const WCHAR *, DWORD, DWORD) DECLSPEC_HIDDEN
 
void destroy_cookies (struct session *) DECLSPEC_HIDDEN
 
BOOL set_server_for_hostname (struct connect *, const WCHAR *, INTERNET_PORT) DECLSPEC_HIDDEN
 
void destroy_authinfo (struct authinfo *) DECLSPEC_HIDDEN
 
void release_host (struct hostdata *) DECLSPEC_HIDDEN
 
BOOL process_header (struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL) DECLSPEC_HIDDEN
 
HRESULT WinHttpRequest_create (void **) DECLSPEC_HIDDEN
 
void release_typelib (void) DECLSPEC_HIDDEN
 
static void__WINE_ALLOC_SIZE (2) heap_realloc_zero(LPVOID mem
 
static WCHARstrdupW (const WCHAR *src)
 
static WCHARstrdupAW (const char *src)
 
static charstrdupWA (const WCHAR *src)
 
static charstrdupWA_sized (const WCHAR *src, DWORD size)
 

Variables

static const WCHAR getW [] = {'G','E','T',0}
 
static const WCHAR postW [] = {'P','O','S','T',0}
 
static const WCHAR headW [] = {'H','E','A','D',0}
 
static const WCHAR slashW [] = {'/',0}
 
static const WCHAR http1_0 [] = {'H','T','T','P','/','1','.','0',0}
 
static const WCHAR http1_1 [] = {'H','T','T','P','/','1','.','1',0}
 
static const WCHAR chunkedW [] = {'c','h','u','n','k','e','d',0}
 
static void SIZE_T size
 
HINSTANCE winhttp_instance DECLSPEC_HIDDEN
 

Enumeration Type Documentation

◆ auth_scheme

Enumerator
SCHEME_INVALID 
SCHEME_BASIC 
SCHEME_NTLM 
SCHEME_PASSPORT 
SCHEME_DIGEST 
SCHEME_NEGOTIATE 
SCHEME_MAX 

Definition at line 146 of file winhttp_private.h.

147{
148 SCHEME_INVALID = -1,
155};
@ SCHEME_BASIC
@ SCHEME_PASSPORT
@ SCHEME_DIGEST
@ SCHEME_INVALID
@ SCHEME_NTLM
@ SCHEME_NEGOTIATE
@ SCHEME_MAX

◆ auth_target

Enumerator
TARGET_INVALID 
TARGET_SERVER 
TARGET_PROXY 
TARGET_MAX 

Definition at line 138 of file winhttp_private.h.

139{
140 TARGET_INVALID = -1,
144};
@ TARGET_MAX
@ TARGET_INVALID
@ TARGET_SERVER
@ TARGET_PROXY

Function Documentation

◆ __WINE_ALLOC_SIZE()

static void * __WINE_ALLOC_SIZE ( )
inlinestatic

◆ add_cookie_headers()

BOOL add_cookie_headers ( struct request request)

Definition at line 324 of file cookie.c.

325{
326 struct list *domain_cursor;
327 struct session *session = request->connect->session;
328
330
331 LIST_FOR_EACH( domain_cursor, &session->cookie_cache )
332 {
333 struct domain *domain = LIST_ENTRY( domain_cursor, struct domain, entry );
334 if (domain_match( request->connect->servername, domain, TRUE ))
335 {
336 struct list *cookie_cursor;
337 TRACE("found domain %s\n", debugstr_w(domain->name));
338
339 LIST_FOR_EACH( cookie_cursor, &domain->cookies )
340 {
341 struct cookie *cookie = LIST_ENTRY( cookie_cursor, struct cookie, entry );
342
343 TRACE("comparing path %s with %s\n", debugstr_w(request->path), debugstr_w(cookie->path));
344
345 if (strstrW( request->path, cookie->path ) == request->path)
346 {
347 static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '};
348 int len, len_cookie = ARRAY_SIZE( cookieW ), len_name = strlenW( cookie->name );
349 WCHAR *header;
350
351 len = len_cookie + len_name;
352 if (cookie->value) len += strlenW( cookie->value ) + 1;
353 if (!(header = heap_alloc( (len + 1) * sizeof(WCHAR) )))
354 {
356 return FALSE;
357 }
358
359 memcpy( header, cookieW, len_cookie * sizeof(WCHAR) );
360 strcpyW( header + len_cookie, cookie->name );
361 if (cookie->value)
362 {
363 header[len_cookie + len_name] = '=';
364 strcpyW( header + len_cookie + len_name + 1, cookie->value );
365 }
366
367 TRACE("%s\n", debugstr_w(header));
370 heap_free( header );
371 }
372 }
373 }
374 }
375
377 return TRUE;
378}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define ARRAY_SIZE(A)
Definition: main.h:33
Definition: list.h:37
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLenum GLsizei len
Definition: glext.h:6722
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define strstrW(d, s)
Definition: unicode.h:32
#define strlenW(s)
Definition: unicode.h:28
#define strcpyW(d, s)
Definition: unicode.h:29
BOOL add_request_headers(struct request *request, const WCHAR *headers, DWORD len, DWORD flags)
Definition: request.c:495
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
#define TRACE(s)
Definition: solgame.cpp:4
Definition: cookie.c:34
WCHAR * name
Definition: cookie.c:36
WCHAR * value
Definition: cookie.c:37
WCHAR * path
Definition: cookie.c:38
Definition: cookie.c:42
WCHAR * name
Definition: cookie.c:44
struct list cookies
Definition: cookie.c:45
Definition: tftpd.h:86
char path[256]
Definition: tftpd.h:94
struct connect * connect
CRITICAL_SECTION cs
struct list cookie_cache
#define LIST_ENTRY(type)
Definition: queue.h:175
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static BOOL domain_match(const WCHAR *name, struct domain *domain, BOOL partial)
Definition: cookie.c:81
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
Definition: winhttp.h:86
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by send_request().

◆ add_request_headers()

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

Definition at line 495 of file request.c.

496{
497 BOOL ret = FALSE;
498 WCHAR *buffer, *p, *q;
499 struct header *header;
500
501 if (len == ~0u) len = strlenW( headers );
502 if (!len) return TRUE;
503 if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
504 memcpy( buffer, headers, len * sizeof(WCHAR) );
505 buffer[len] = 0;
506
507 p = buffer;
508 do
509 {
510 q = p;
511 while (*q)
512 {
513 if (q[0] == '\n' && q[1] == '\r')
514 {
515 q[0] = '\r';
516 q[1] = '\n';
517 }
518 if (q[0] == '\r' && q[1] == '\n') break;
519 q++;
520 }
521 if (!*p) break;
522 if (*q == '\r')
523 {
524 *q = 0;
525 q += 2; /* jump over \r\n */
526 }
527 if ((header = parse_header( p )))
528 {
531 }
532 p = q;
533 } while (ret);
534
535 heap_free( buffer );
536 return ret;
537}
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLuint buffer
Definition: glext.h:5915
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
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 process_header(struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only)
Definition: request.c:430
static void free_header(struct header *header)
Definition: request.c:297
unsigned int len
Definition: request.c:891
static struct header * parse_header(const WCHAR *string)
Definition: request.c:325
vector< Header * > headers
Definition: sdkparse.cpp:39
WCHAR * field
WCHAR * value
int ret

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

◆ addref_object()

struct object_header * addref_object ( struct object_header hdr)

Definition at line 49 of file handle.c.

50{
51 ULONG refs = InterlockedIncrement( &hdr->refs );
52 TRACE("%p -> refcount = %d\n", hdr, refs);
53 return hdr;
54}
#define InterlockedIncrement
Definition: armddk.h:53
char hdr[14]
Definition: iptest.cpp:33
uint32_t ULONG
Definition: typedefs.h:59

Referenced by alloc_handle(), grab_object(), WinHttpConnect(), WinHttpOpenRequest(), WinHttpQueryDataAvailable(), WinHttpReadData(), WinHttpReceiveResponse(), WinHttpSendRequest(), and WinHttpWriteData().

◆ alloc_handle()

HINTERNET alloc_handle ( struct object_header hdr)

Definition at line 88 of file handle.c.

89{
90 struct object_header **p;
92
93 list_init( &hdr->children );
94 hdr->handle = NULL;
95
97 if (!max_handles)
98 {
100 if (!(p = heap_alloc_zero( sizeof(ULONG_PTR) * num ))) goto end;
101 handles = p;
103 }
105 {
106 num = max_handles * 2;
107 if (!(p = heap_realloc_zero( handles, sizeof(ULONG_PTR) * num ))) goto end;
108 handles = p;
110 }
112 if (handles[handle]) ERR("handle isn't free but should be\n");
113
115 hdr->handle = (HINTERNET)(handle + 1);
117
118end:
120 return hdr->handle;
121}
static void list_init(struct list_entry *head)
Definition: list.h:51
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
static CRITICAL_SECTION handle_cs
Definition: handle.c:36
#define HANDLE_CHUNK_SIZE
Definition: handle.c:34
static struct object_header ** handles
Definition: handle.c:45
static ULONG_PTR max_handles
Definition: handle.c:47
struct object_header * addref_object(struct object_header *hdr)
Definition: handle.c:49
static ULONG_PTR next_handle
Definition: handle.c:46
GLuint GLuint end
Definition: gl.h:1545
GLuint GLuint num
Definition: glext.h:9618
HINTERNET handle
uint32_t ULONG_PTR
Definition: typedefs.h:65
LPVOID HINTERNET
Definition: winhttp.h:32

◆ close_connection()

void close_connection ( struct request request)

Definition at line 1809 of file request.c.

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

◆ destroy_authinfo()

void destroy_authinfo ( struct authinfo authinfo)

Definition at line 1138 of file request.c.

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

Referenced by do_authorization().

◆ destroy_cookies()

void destroy_cookies ( struct session session)

Definition at line 120 of file cookie.c.

121{
122 struct list *item, *next;
123 struct domain *domain;
124
126 {
127 domain = LIST_ENTRY( item, struct domain, entry );
129 }
130}
static ATOM item
Definition: dde.c:856
static unsigned __int64 next
Definition: rand_nt.c:6
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:192
static void delete_domain(struct domain *domain)
Definition: cookie.c:104

Referenced by session_destroy().

◆ free_handle()

BOOL free_handle ( HINTERNET  hinternet)

Definition at line 123 of file handle.c.

124{
125 BOOL ret = FALSE;
126 ULONG_PTR handle = (ULONG_PTR)hinternet;
127 struct object_header *hdr = NULL, *child, *next;
128
130
131 if ((handle > 0) && (handle <= max_handles))
132 {
133 handle--;
134 if (handles[handle])
135 {
136 hdr = handles[handle];
137 TRACE("destroying handle 0x%lx for object %p\n", handle + 1, hdr);
139 ret = TRUE;
140 }
141 }
142
144
145 if (hdr)
146 {
148 {
149 TRACE("freeing child handle %p for parent handle 0x%lx\n", child->handle, handle + 1);
150 free_handle( child->handle );
151 }
153 }
154
158
159 return ret;
160}
BOOL free_handle(HINTERNET hinternet)
Definition: handle.c:123
void release_object(struct object_header *hdr)
Definition: handle.c:72
#define ULONG_PTR
Definition: config.h:101
static HWND child
Definition: cursoricon.c:298
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204

Referenced by free_handle(), pqInsert(), and WinHttpCloseHandle().

◆ grab_object()

◆ netconn_close()

void netconn_close ( struct netconn conn)

Definition at line 250 of file net.c.

251{
252 if (conn->secure)
253 {
254 heap_free( conn->peek_msg_mem );
255 heap_free(conn->ssl_buf);
256 heap_free(conn->extra_buf);
258 }
259 closesocket( conn->socket );
260 release_host( conn->host );
261 heap_free(conn);
262}
#define closesocket
Definition: ncftp.h:477
void release_host(struct hostdata *host)
Definition: request.c:1494
struct hostdata * host
char * extra_buf
char * peek_msg_mem
CtxtHandle ssl_ctx
char * ssl_buf

Referenced by close_connection(), connection_collector(), handle_redirect(), and open_connection().

◆ netconn_create()

struct netconn * netconn_create ( struct hostdata host,
const struct sockaddr_storage sockaddr,
int  timeout 
)

Definition at line 186 of file net.c.

187{
188 struct netconn *conn;
189 unsigned int addr_len;
190 BOOL ret = FALSE;
191
192#ifndef __REACTOS__
193 winsock_init();
194#endif
195
196 conn = heap_alloc_zero(sizeof(*conn));
197 if (!conn) return NULL;
198 conn->host = host;
199 conn->sockaddr = *sockaddr;
200 if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1)
201 {
202 WARN("unable to create socket (%u)\n", WSAGetLastError());
203 heap_free(conn);
204 return NULL;
205 }
206
207 switch (conn->sockaddr.ss_family)
208 {
209 case AF_INET:
210 addr_len = sizeof(struct sockaddr_in);
211 break;
212 case AF_INET6:
213 addr_len = sizeof(struct sockaddr_in6);
214 break;
215 default:
216 assert(0);
217 }
218
219 if (timeout > 0) set_blocking( conn, FALSE );
220
221 if (!connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len )) ret = TRUE;
222 else
223 {
226 {
227 FD_SET set;
228 TIMEVAL timeval = { 0, timeout * 1000 };
229 int res;
230
231 FD_ZERO( &set );
232 FD_SET( conn->socket, &set );
233 if ((res = select( conn->socket + 1, NULL, &set, NULL, &timeval )) > 0) ret = TRUE;
235 }
236 }
237
238 if (timeout > 0) set_blocking( conn, TRUE );
239
240 if (!ret)
241 {
242 WARN("unable to connect to host (%u)\n", GetLastError());
243 closesocket( conn->socket );
244 heap_free( conn );
245 return NULL;
246 }
247 return conn;
248}
#define WARN(fmt,...)
Definition: debug.h:112
Definition: _set.h:50
#define SetLastError(x)
Definition: compat.h:752
static void winsock_init(void)
Definition: net.c:173
static void set_blocking(struct netconn *conn, BOOL blocking)
Definition: net.c:180
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
#define assert(x)
Definition: debug.h:53
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
#define err(...)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
Definition: winsock.h:66
struct sockaddr_storage sockaddr
Definition: dhcpd.h:245
char * host
Definition: whois.c:55
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define WSAEINPROGRESS
Definition: winerror.h:1949
#define ERROR_WINHTTP_TIMEOUT
Definition: winhttp.h:189
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112
#define FD_ZERO(set)
Definition: winsock.h:96
#define AF_INET6
Definition: winsock.h:369
#define FD_SET(fd, set)
Definition: winsock.h:89

Referenced by open_connection().

◆ netconn_get_certificate()

const void * netconn_get_certificate ( struct netconn conn)

Definition at line 758 of file net.c.

759{
760 const CERT_CONTEXT *ret;
762
763 if (!conn->secure) return NULL;
765 return res == SEC_E_OK ? ret : NULL;
766}
LONG SECURITY_STATUS
Definition: sspi.h:34
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
Definition: schannel.h:69
#define SEC_E_OK
Definition: winerror.h:2356
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535

Referenced by open_connection().

◆ netconn_get_cipher_strength()

int netconn_get_cipher_strength ( struct netconn conn)

Definition at line 768 of file net.c.

769{
772
773 if (!conn->secure) return 0;
775 if(res != SEC_E_OK)
776 WARN("QueryContextAttributesW failed: %08x\n", res);
777 return res == SEC_E_OK ? conn_info.dwCipherStrength : 0;
778}
#define SECPKG_ATTR_CONNECTION_INFO
Definition: schannel.h:76

Referenced by request_query_option().

◆ netconn_is_alive()

BOOL netconn_is_alive ( struct netconn netconn)

Definition at line 608 of file net.c.

609{
610 int len;
611 char b;
612 DWORD err;
613
615 len = sock_recv( netconn->socket, &b, 1, MSG_PEEK );
618
619 return len == 1 || (len == -1 && err == WSAEWOULDBLOCK);
620}
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:49
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
#define MSG_PEEK
Definition: winsock.h:222

Referenced by open_connection().

◆ netconn_query_data_available()

ULONG netconn_query_data_available ( struct netconn conn)

Definition at line 591 of file net.c.

592{
593 return conn->secure ? conn->peek_len : 0;
594}
size_t peek_len

Referenced by query_data_available().

◆ netconn_recv()

BOOL netconn_recv ( struct netconn conn,
void buf,
size_t  len,
int  flags,
int recvd 
)

Definition at line 539 of file net.c.

540{
541 *recvd = 0;
542 if (!len) return TRUE;
543
544 if (conn->secure)
545 {
546 SIZE_T size, cread;
547 BOOL res, eof;
548
549 if (conn->peek_msg)
550 {
551 *recvd = min( len, conn->peek_len );
552 memcpy( buf, conn->peek_msg, *recvd );
553 conn->peek_len -= *recvd;
554 conn->peek_msg += *recvd;
555
556 if (conn->peek_len == 0)
557 {
558 heap_free( conn->peek_msg_mem );
559 conn->peek_msg_mem = NULL;
560 conn->peek_msg = NULL;
561 }
562 /* check if we have enough data from the peek buffer */
563 if (!(flags & MSG_WAITALL) || *recvd == len) return TRUE;
564 }
565 size = *recvd;
566
567 do {
568 res = read_ssl_chunk(conn, (BYTE*)buf+size, len-size, &cread, &eof);
569 if(!res) {
570 WARN("read_ssl_chunk failed\n");
571 if(!size)
572 return FALSE;
573 break;
574 }
575
576 if(eof) {
577 TRACE("EOF\n");
578 break;
579 }
580
581 size += cread;
582 }while(!size || ((flags & MSG_WAITALL) && size < len));
583
584 TRACE("received %ld bytes\n", size);
585 *recvd = size;
586 return TRUE;
587 }
588 return ((*recvd = sock_recv( conn->socket, buf, len, flags )) != -1);
589}
static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZE_T *ret_size, BOOL *eof)
Definition: net.c:448
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define min(a, b)
Definition: monoChain.cc:55
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
char * peek_msg
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned char BYTE
Definition: xxhash.c:193

Referenced by read_more_data().

◆ netconn_resolve()

BOOL netconn_resolve ( WCHAR hostname,
INTERNET_PORT  port,
struct sockaddr_storage addr,
int  timeout 
)

Definition at line 725 of file net.c.

726{
727 DWORD ret;
728
730 else
731 {
732 struct async_resolve async;
733
734 async.hostname = hostname;
735 async.port = port;
736 async.addr = addr;
737 if (!(async.done = CreateEventW( NULL, FALSE, FALSE, NULL ))) return FALSE;
738 if (!TrySubmitThreadpoolCallback( resolve_proc, &async, NULL ))
739 {
740 CloseHandle( async.done );
741 return FALSE;
742 }
744 else ret = async.result;
745 CloseHandle( async.done );
746 }
747
748 if (ret)
749 {
750 SetLastError( ret );
751 return FALSE;
752 }
753 return TRUE;
754}
char * hostname
Definition: ftp.c:88
#define CloseHandle
Definition: compat.h:739
USHORT port
Definition: uri.c:228
static void CALLBACK resolve_proc(TP_CALLBACK_INSTANCE *instance, void *ctx)
Definition: net.c:718
static DWORD resolve_hostname(const WCHAR *name, INTERNET_PORT port, struct sockaddr_storage *sa)
Definition: net.c:622
GLenum const GLvoid * addr
Definition: glext.h:9621
const WCHAR * hostname
Definition: net.c:711
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define WAIT_OBJECT_0
Definition: winbase.h:406

Referenced by open_connection().

◆ netconn_secure_connect()

BOOL netconn_secure_connect ( struct netconn conn,
WCHAR hostname,
DWORD  security_flags,
CredHandle cred_handle,
BOOL  check_revocation 
)

Definition at line 264 of file net.c.

266{
267 SecBuffer out_buf = {0, SECBUFFER_TOKEN, NULL}, in_bufs[2] = {{0, SECBUFFER_TOKEN}, {0, SECBUFFER_EMPTY}};
268 SecBufferDesc out_desc = {SECBUFFER_VERSION, 1, &out_buf}, in_desc = {SECBUFFER_VERSION, 2, in_bufs};
269 BYTE *read_buf;
270 SIZE_T read_buf_size = 2048;
271 ULONG attrs = 0;
274 const CERT_CONTEXT *cert;
277
280
281 read_buf = heap_alloc(read_buf_size);
282 if(!read_buf)
283 return FALSE;
284
285 status = InitializeSecurityContextW(cred_handle, NULL, hostname, isc_req_flags, 0, 0, NULL, 0,
286 &ctx, &out_desc, &attrs, NULL);
287
289
291 if(out_buf.cbBuffer) {
293
294 TRACE("sending %u bytes\n", out_buf.cbBuffer);
295
296 size = sock_send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0);
297 if(size != out_buf.cbBuffer) {
298 ERR("send failed\n");
300 break;
301 }
302
303 FreeContextBuffer(out_buf.pvBuffer);
304 out_buf.pvBuffer = NULL;
305 out_buf.cbBuffer = 0;
306 }
307
309 assert(in_bufs[1].cbBuffer < read_buf_size);
310
311 memmove(read_buf, (BYTE*)in_bufs[0].pvBuffer+in_bufs[0].cbBuffer-in_bufs[1].cbBuffer, in_bufs[1].cbBuffer);
312 in_bufs[0].cbBuffer = in_bufs[1].cbBuffer;
313
314 in_bufs[1].BufferType = SECBUFFER_EMPTY;
315 in_bufs[1].cbBuffer = 0;
316 in_bufs[1].pvBuffer = NULL;
317 }
318
319 assert(in_bufs[0].BufferType == SECBUFFER_TOKEN);
320 assert(in_bufs[1].BufferType == SECBUFFER_EMPTY);
321
322 if(in_bufs[0].cbBuffer + 1024 > read_buf_size) {
323 BYTE *new_read_buf;
324
325 new_read_buf = heap_realloc(read_buf, read_buf_size + 1024);
326 if(!new_read_buf) {
328 break;
329 }
330
331 in_bufs[0].pvBuffer = read_buf = new_read_buf;
332 read_buf_size += 1024;
333 }
334
335 size = sock_recv(conn->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0);
336 if(size < 1) {
338 break;
339 }
340
341 TRACE("recv %lu bytes\n", size);
342
343 in_bufs[0].cbBuffer += size;
344 in_bufs[0].pvBuffer = read_buf;
345 status = InitializeSecurityContextW(cred_handle, &ctx, hostname, isc_req_flags, 0, 0, &in_desc,
346 0, NULL, &out_desc, &attrs, NULL);
347 TRACE("InitializeSecurityContext ret %08x\n", status);
348
349 if(status == SEC_E_OK) {
350 if(in_bufs[1].BufferType == SECBUFFER_EXTRA)
351 FIXME("SECBUFFER_EXTRA not supported\n");
352
354 if(status != SEC_E_OK) {
355 WARN("Could not get sizes\n");
356 break;
357 }
358
360 if(status == SEC_E_OK) {
361 res = netconn_verify_cert(cert, hostname, security_flags, check_revocation);
363 if(res != ERROR_SUCCESS) {
364 WARN("cert verify failed: %u\n", res);
365 break;
366 }
367 }else {
368 WARN("Could not get cert\n");
369 break;
370 }
371
373 if(!conn->ssl_buf) {
374 res = GetLastError();
375 break;
376 }
377 }
378 }
379
381
382 if(status != SEC_E_OK || res != ERROR_SUCCESS) {
383 WARN("Failed to initialize security context failed: %08x\n", status);
384 heap_free(conn->ssl_buf);
385 conn->ssl_buf = NULL;
388 return FALSE;
389 }
390
391
392 TRACE("established SSL connection\n");
393 conn->secure = TRUE;
394 conn->ssl_ctx = ctx;
395 return TRUE;
396}
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
LONG_PTR SSIZE_T
Definition: basetsd.h:181
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
static int sock_send(int fd, const void *msg, size_t len, int flags)
Definition: net.c:38
static DWORD netconn_verify_cert(PCCERT_CONTEXT cert, WCHAR *server, DWORD security_flags, BOOL check_revocation)
Definition: net.c:60
#define read_buf
Definition: intsym.h:279
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static BYTE cert[]
Definition: msg.c:1437
static SecHandle cred_handle
#define ISC_REQ_MANUAL_CRED_VALIDATION
Definition: sspi.h:381
#define ISC_REQ_CONFIDENTIALITY
Definition: sspi.h:366
#define ISC_REQ_ALLOCATE_MEMORY
Definition: sspi.h:370
#define SECBUFFER_TOKEN
Definition: sspi.h:161
#define ISC_REQ_SEQUENCE_DETECT
Definition: sspi.h:365
#define ISC_REQ_REPLAY_DETECT
Definition: sspi.h:364
#define ISC_REQ_USE_SESSION_KEY
Definition: sspi.h:367
#define SECBUFFER_EXTRA
Definition: sspi.h:164
#define SECPKG_ATTR_STREAM_SIZES
Definition: sspi.h:525
#define SECBUFFER_VERSION
Definition: sspi.h:187
#define SECBUFFER_EMPTY
Definition: sspi.h:159
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
Definition: sspi.c:699
ULONG cbBuffer
Definition: sspi.h:153
SecPkgContext_StreamSizes ssl_sizes
Definition: ps.c:97
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:2927
#define SEC_E_INCOMPLETE_MESSAGE
Definition: winerror.h:2934
#define ERROR_WINHTTP_SECURE_CHANNEL_ERROR
Definition: winhttp.h:219
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

Referenced by open_connection().

◆ netconn_send()

BOOL netconn_send ( struct netconn conn,
const void msg,
size_t  len,
int sent 
)

Definition at line 424 of file net.c.

425{
426 if (conn->secure)
427 {
428 const BYTE *ptr = msg;
429 size_t chunk_size;
430
431 *sent = 0;
432
433 while(len) {
434 chunk_size = min(len, conn->ssl_sizes.cbMaximumMessage);
435 if(!send_ssl_chunk(conn, ptr, chunk_size))
436 return FALSE;
437
438 *sent += chunk_size;
439 ptr += chunk_size;
440 len -= chunk_size;
441 }
442
443 return TRUE;
444 }
445 return ((*sent = sock_send( conn->socket, msg, len, 0 )) != -1);
446}
@ sent
Definition: SystemMenu.c:27
#define msg(x)
Definition: auth_time.c:54
static BOOL send_ssl_chunk(struct netconn *conn, const void *msg, size_t size)
Definition: net.c:398
static PVOID ptr
Definition: dispmode.c:27

Referenced by secure_proxy_connect(), send_request(), and write_data().

◆ netconn_set_timeout()

DWORD netconn_set_timeout ( struct netconn netconn,
BOOL  send,
int  value 
)

Definition at line 596 of file net.c.

597{
598 int opt = send ? SO_SNDTIMEO : SO_RCVTIMEO;
599 if (setsockopt( netconn->socket, SOL_SOCKET, opt, (void *)&value, sizeof(value) ) == -1)
600 {
602 WARN("setsockopt failed (%u)\n", err );
603 return err;
604 }
605 return ERROR_SUCCESS;
606}
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
Definition: pdh_main.c:94
#define SOL_SOCKET
Definition: winsock.h:398
#define SO_SNDTIMEO
Definition: winsock.h:192
#define SO_RCVTIMEO
Definition: winsock.h:193

Referenced by open_connection(), receive_response(), and WinHttpSetTimeouts().

◆ netconn_unload()

void netconn_unload ( void  )

Definition at line 156 of file net.c.

157{
159}
static BOOL winsock_loaded
Definition: net.c:154
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60

Referenced by DllMain().

◆ process_header()

BOOL process_header ( struct request request,
const WCHAR field,
const WCHAR value,
DWORD  flags,
BOOL  request_only 
)

Definition at line 430 of file request.c.

431{
432 int index;
433 struct header hdr;
434
435 TRACE("%s: %s 0x%08x\n", debugstr_w(field), debugstr_w(value), flags);
436
437 if ((index = get_header_index( request, field, 0, request_only )) >= 0)
438 {
440 }
441
443 {
444 if (index >= 0)
445 {
447 if (!value || !value[0]) return TRUE;
448 }
449 else if (!(flags & WINHTTP_ADDREQ_FLAG_ADD))
450 {
452 return FALSE;
453 }
454
455 hdr.field = (LPWSTR)field;
456 hdr.value = (LPWSTR)value;
457 hdr.is_request = request_only;
458 return insert_header( request, &hdr );
459 }
460 else if (value)
461 {
462
464 index >= 0)
465 {
466 WCHAR *tmp;
467 int len, len_orig, len_value;
468 struct header *header = &request->headers[index];
469
470 len_orig = strlenW( header->value );
471 len_value = strlenW( value );
472
473 len = len_orig + len_value + 2;
474 if (!(tmp = heap_realloc( header->value, (len + 1) * sizeof(WCHAR) ))) return FALSE;
475 header->value = tmp;
476 header->value[len_orig++] = (flags & WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA) ? ',' : ';';
477 header->value[len_orig++] = ' ';
478
479 memcpy( &header->value[len_orig], value, len_value * sizeof(WCHAR) );
480 header->value[len] = 0;
481 return TRUE;
482 }
483 else
484 {
485 hdr.field = (LPWSTR)field;
486 hdr.value = (LPWSTR)value;
487 hdr.is_request = request_only;
488 return insert_header( request, &hdr );
489 }
490 }
491
492 return TRUE;
493}
#define index(s, c)
Definition: various.h:29
GLuint index
Definition: glext.h:6031
static BOOL delete_header(struct request *request, DWORD index)
Definition: request.c:415
static BOOL insert_header(struct request *request, struct header *header)
Definition: request.c:396
static int get_header_index(struct request *request, const WCHAR *field, int requested_index, BOOL request_only)
Definition: request.c:376
Definition: parser.c:44
struct header * headers
#define WINHTTP_ADDREQ_FLAG_ADD_IF_NEW
Definition: winhttp.h:83
#define WINHTTP_ADDREQ_FLAG_REPLACE
Definition: winhttp.h:88
#define ERROR_WINHTTP_HEADER_NOT_FOUND
Definition: winhttp.h:213
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Definition: winhttp.h:85
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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

◆ release_host()

void release_host ( struct hostdata host)

Definition at line 1494 of file request.c.

1495{
1496 LONG ref;
1497
1499 if (!(ref = --host->ref)) list_remove( &host->entry );
1501 if (ref) return;
1502
1503 assert( list_empty( &host->connections ) );
1504 heap_free( host->hostname );
1505 heap_free( host );
1506}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static int list_empty(struct list_entry *head)
Definition: list.h:58
long LONG
Definition: pedump.c:60
static CRITICAL_SECTION connection_pool_cs
Definition: request.c:1483
Definition: send.c:48

Referenced by netconn_close(), and open_connection().

◆ release_object()

void release_object ( struct object_header hdr)

Definition at line 72 of file handle.c.

73{
74 ULONG refs = InterlockedDecrement( &hdr->refs );
75 TRACE("object %p refcount = %d\n", hdr, refs);
76 if (!refs)
77 {
79
81
82 TRACE("destroying object %p\n", hdr);
83 if (hdr->type != WINHTTP_HANDLE_TYPE_SESSION) list_remove( &hdr->entry );
84 hdr->vtbl->destroy( hdr );
85 }
86}
#define InterlockedDecrement
Definition: armddk.h:52
static void close_connection(void)
Definition: http.c:5576
#define WINHTTP_HANDLE_TYPE_REQUEST
Definition: winhttp.h:432
#define WINHTTP_HANDLE_TYPE_SESSION
Definition: winhttp.h:430
#define WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
Definition: winhttp.h:391

Referenced by connect_destroy(), free_handle(), request_destroy(), task_proc(), WinHttpAddRequestHeaders(), WinHttpCloseHandle(), WinHttpConnect(), WinHttpGetProxyForUrl(), WinHttpOpen(), WinHttpOpenRequest(), WinHttpQueryAuthSchemes(), WinHttpQueryDataAvailable(), WinHttpQueryHeaders(), WinHttpQueryOption(), WinHttpReadData(), WinHttpReceiveResponse(), WinHttpSendRequest(), WinHttpSetCredentials(), WinHttpSetOption(), WinHttpSetStatusCallback(), WinHttpSetTimeouts(), and WinHttpWriteData().

◆ release_typelib()

void release_typelib ( void  )

Definition at line 159 of file apps.c.

160{
161 unsigned i;
162
163 for (i = 0; i < ARRAY_SIZE(typeinfo); i++)
164 if (typeinfo[i])
165 ITypeInfo_Release(typeinfo[i]);
166
167 if (typelib)
168 ITypeLib_Release(typelib);
169}
static ITypeLib * typelib
Definition: apps.c:108
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

Referenced by DllMain(), and process_detach().

◆ send_callback()

void send_callback ( struct object_header ,
DWORD  ,
LPVOID  ,
DWORD   
)

◆ set_cookies()

BOOL set_cookies ( struct request request,
const WCHAR cookies 
)

Definition at line 263 of file cookie.c.

264{
265 static const WCHAR pathW[] = {'p','a','t','h',0};
266 static const WCHAR domainW[] = {'d','o','m','a','i','n',0};
267 BOOL ret = FALSE;
268 WCHAR *buffer, *p;
269 WCHAR *cookie_domain = NULL, *cookie_path = NULL;
270 struct attr *attr, *domain = NULL, *path = NULL;
271 struct session *session = request->connect->session;
272 struct cookie *cookie;
273 int len, used;
274
275 len = strlenW( cookies );
276 if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
278
279 p = buffer;
280 while (*p && *p != ';') p++;
281 if (*p == ';') *p++ = 0;
282 if (!(cookie = parse_cookie( buffer )))
283 {
284 heap_free( buffer );
285 return FALSE;
286 }
287 len = strlenW( p );
288 while (len && (attr = parse_attr( p, &used )))
289 {
290 if (!strcmpiW( attr->name, domainW ))
291 {
292 domain = attr;
293 cookie_domain = attr->value;
294 }
295 else if (!strcmpiW( attr->name, pathW ))
296 {
297 path = attr;
298 cookie_path = attr->value;
299 }
300 else
301 {
302 FIXME( "unhandled attribute %s\n", debugstr_w(attr->name) );
303 free_attr( attr );
304 }
305 len -= used;
306 p += used;
307 }
308 if (!cookie_domain && !(cookie_domain = strdupW( request->connect->servername ))) goto end;
309 if (!cookie_path && !(cookie_path = strdupW( request->path ))) goto end;
310
311 if ((p = strrchrW( cookie_path, '/' )) && p != cookie_path) *p = 0;
312 ret = add_cookie( session, cookie, cookie_domain, cookie_path );
313
314end:
315 if (!ret) free_cookie( cookie );
316 if (domain) free_attr( domain );
317 else heap_free( cookie_domain );
318 if (path) free_attr( path );
319 else heap_free( cookie_path );
320 heap_free( buffer );
321 return ret;
322}
static int used
Definition: adh-main.c:39
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
static CookieInternal * cookies
Definition: msctf.c:65
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define strrchrW(s, c)
Definition: unicode.h:35
Definition: cookie.c:202
WCHAR * value
Definition: cookie.c:204
WCHAR * name
Definition: cookie.c:203
static struct attr * parse_attr(const WCHAR *str, int *used)
Definition: cookie.c:215
static struct cookie * parse_cookie(const WCHAR *string)
Definition: cookie.c:162
static BOOL add_cookie(struct session *session, struct cookie *cookie, WCHAR *domain_name, WCHAR *path)
Definition: cookie.c:132
static void free_attr(struct attr *attr)
Definition: cookie.c:207
void free_cookie(void)
Definition: cookie.c:1269

Referenced by record_cookies().

◆ set_server_for_hostname()

BOOL set_server_for_hostname ( struct connect connect,
const WCHAR server,
INTERNET_PORT  port 
)

Definition at line 476 of file session.c.

477{
478 struct session *session = connect->session;
479 BOOL ret = TRUE;
480
482 {
483 LPCWSTR colon;
484
485 if ((colon = strchrW( session->proxy_server, ':' )))
486 {
488 session->proxy_server, colon - session->proxy_server - 1 ))
489 {
493 (colon - session->proxy_server + 1) * sizeof(WCHAR) )))
494 {
495 ret = FALSE;
496 goto end;
497 }
499 (colon - session->proxy_server) * sizeof(WCHAR) );
500 connect->servername[colon - session->proxy_server] = 0;
501 if (*(colon + 1))
502 connect->serverport = atoiW( colon + 1 );
503 else
505 }
506 }
507 else
508 {
511 {
515 {
516 ret = FALSE;
517 goto end;
518 }
520 }
521 }
522 }
523 else if (server)
524 {
527 if (!(connect->servername = strdupW( server )))
528 {
529 ret = FALSE;
530 goto end;
531 }
533 }
534end:
535 return ret;
536}
static BOOL should_bypass_proxy(struct session *session, LPCWSTR server)
Definition: session.c:445
#define atoiW(s)
Definition: unicode.h:54
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define strchrW(s, c)
Definition: unicode.h:34
struct session * session
WCHAR * servername
INTERNET_PORT serverport
WCHAR * proxy_server
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define INTERNET_DEFAULT_PORT
Definition: winhttp.h:35
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by handle_redirect(), and WinHttpConnect().

◆ strdupAW()

static WCHAR * strdupAW ( const char src)
inlinestatic

Definition at line 316 of file winhttp_private.h.

317{
318 WCHAR *dst = NULL;
319 if (src)
320 {
321 DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
322 if ((dst = heap_alloc( len * sizeof(WCHAR) )))
323 MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
324 }
325 return dst;
326}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ strdupW()

static WCHAR * strdupW ( const WCHAR src)
inlinestatic

Definition at line 306 of file winhttp_private.h.

307{
308 WCHAR *dst;
309
310 if (!src) return NULL;
311 dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) );
312 if (dst) strcpyW( dst, src );
313 return dst;
314}

◆ strdupWA()

static char * strdupWA ( const WCHAR src)
inlinestatic

Definition at line 328 of file winhttp_private.h.

329{
330 char *dst = NULL;
331 if (src)
332 {
333 int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
334 if ((dst = heap_alloc( len )))
336 }
337 return dst;
338}
#define WideCharToMultiByte
Definition: compat.h:111

◆ strdupWA_sized()

static char * strdupWA_sized ( const WCHAR src,
DWORD  size 
)
inlinestatic

Definition at line 340 of file winhttp_private.h.

341{
342 char *dst = NULL;
343 if (src)
344 {
345 int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
346 if ((dst = heap_alloc( len )))
347 {
349 dst[len - 1] = 0;
350 }
351 }
352 return dst;
353}

Referenced by run_script().

◆ WinHttpRequest_create()

HRESULT WinHttpRequest_create ( void **  obj)

Definition at line 4782 of file request.c.

4783{
4784 struct winhttp_request *request;
4785
4786 TRACE("%p\n", obj);
4787
4788 if (!(request = heap_alloc_zero( sizeof(*request) ))) return E_OUTOFMEMORY;
4789 request->IWinHttpRequest_iface.lpVtbl = &winhttp_request_vtbl;
4790 request->refs = 1;
4792 request->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": winhttp_request.cs");
4794
4795 *obj = &request->IWinHttpRequest_iface;
4796 TRACE("returning iface %p\n", *obj);
4797 return S_OK;
4798}
#define S_OK
Definition: intsafe.h:52
static const struct IWinHttpRequestVtbl winhttp_request_vtbl
Definition: request.c:4752
static void initialize_request(struct winhttp_request *request)
Definition: request.c:3589
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define DWORD_PTR
Definition: treelist.c:76

Variable Documentation

◆ chunkedW

const WCHAR chunkedW[] = {'c','h','u','n','k','e','d',0}
static

Definition at line 40 of file winhttp_private.h.

Referenced by set_content_length().

◆ DECLSPEC_HIDDEN

HINSTANCE winhttp_instance DECLSPEC_HIDDEN
extern

Definition at line 289 of file d3dcompiler_private.h.

◆ getW

const WCHAR getW[] = {'G','E','T',0}
static

Definition at line 34 of file winhttp_private.h.

◆ headW

const WCHAR headW[] = {'H','E','A','D',0}
static

Definition at line 36 of file winhttp_private.h.

◆ http1_0

const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0}
static

Definition at line 38 of file winhttp_private.h.

Referenced by finished_reading().

◆ http1_1

const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0}
static

Definition at line 39 of file winhttp_private.h.

Referenced by build_proxy_connect_string(), and WinHttpOpenRequest().

◆ postW

const WCHAR postW[] = {'P','O','S','T',0}
static

◆ size

Initial value:
{
#define GetProcessHeap()
Definition: compat.h:736
#define HeapReAlloc
Definition: compat.h:734
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
Definition: mem.c:156

Definition at line 301 of file winhttp_private.h.

◆ slashW

const WCHAR slashW[] = {'/',0}
static

Definition at line 37 of file winhttp_private.h.