ReactOS 0.4.15-dev-7928-g68a8619
http.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "windef.h"
#include "winbase.h"
#include "wininet.h"
#include "winineti.h"
#include "winsock2.h"
#include "wine/test.h"
Include dependency graph for http.c:

Go to the source code of this file.

Classes

struct  test_data_t
 
struct  test_request_t
 
struct  server_info
 
struct  http_status_test_t
 
struct  large_test
 
struct  cert_struct_test_t
 
struct  context
 
struct  notification
 
struct  info
 
struct  notification_data
 

Macros

#define _SECURITY_FLAG_CERT_REV_FAILED   0x00800000
 
#define _SECURITY_FLAG_CERT_INVALID_CA   0x01000000
 
#define _SECURITY_FLAG_CERT_INVALID_CN   0x02000000
 
#define _SECURITY_FLAG_CERT_INVALID_DATE   0x04000000
 
#define TEST_URL   "http://test.winehq.org/tests/hello.html"
 
#define SET_EXPECT2(status, num)    expect[status] = num
 
#define SET_EXPECT(status)    SET_EXPECT2(status, 1)
 
#define SET_OPTIONAL2(status, num)    optional[status] = num
 
#define SET_OPTIONAL(status)    SET_OPTIONAL2(status, 1)
 
#define SET_WINE_ALLOW2(status, num)    wine_allow[status] = num
 
#define SET_WINE_ALLOW(status)    SET_WINE_ALLOW2(status, 1)
 
#define CHECK_EXPECT(status)
 
#define CLEAR_NOTIFIED(status)    expect[status] = optional[status] = wine_allow[status] = notified[status] = 0;
 
#define CHECK_NOTIFIED2(status, num)
 
#define CHECK_NOTIFIED(status)    CHECK_NOTIFIED2(status, 1)
 
#define CHECK_NOT_NOTIFIED(status)    CHECK_NOTIFIED2(status, 0)
 
#define MAX_INTERNET_STATUS   (INTERNET_STATUS_COOKIE_HISTORY+1)
 
#define TESTF_REDIRECT   0x01
 
#define TESTF_COMPRESSED   0x02
 
#define TESTF_CHUNKED   0x04
 
#define test_status_code(a, b)   _test_status_code(__LINE__,a,b, FALSE)
 
#define test_status_code_todo(a, b)   _test_status_code(__LINE__,a,b, TRUE)
 
#define test_request_flags(a, b)   _test_request_flags(__LINE__,a,b,FALSE)
 
#define test_request_flags_todo(a, b)   _test_request_flags(__LINE__,a,b,TRUE)
 
#define test_request_url(a, b)   _test_request_url(__LINE__,a,b)
 
#define test_http_version(a)   _test_http_version(__LINE__,a)
 
#define open_simple_request(a, b, c, d, e)   _open_simple_request(__LINE__,a,b,c,d,e)
 
#define close_request(a)   _close_request(__LINE__,a)
 
#define receive_simple_request(a, b, c)   _receive_simple_request(__LINE__,a,b,c)
 
#define server_read_request(a)   _server_read_request(__LINE__,a)
 
#define readex_expect_sync_data_len(a, b, c, d, e, f, g)   _readex_expect_sync_data_len(__LINE__,a,b,c,d,e,f,g)
 
#define readex_expect_sync_data(a, b, c, d, e, f)   _readex_expect_sync_data(__LINE__,a,b,c,d,e,f)
 
#define read_expect_sync_data_len(a, b, c, d, e)   _read_expect_sync_data_len(__LINE__,a,b,c,d,e)
 
#define read_expect_sync_data(a, b, c, d)   _read_expect_sync_data(__LINE__,a,b,c,d)
 
#define send_response_and_wait(a, b, c, d, e, f, g, h)   _send_response_and_wait(__LINE__,a,b,c,d,e,f,g,h)
 
#define send_response_ex_and_wait(a, b, c, d, e, f)   _send_response_ex_and_wait(__LINE__,a,b,c,d,e,f)
 
#define readex_expect_async(a, b, c, d, e)   _readex_expect_async(__LINE__,a,b,c,d,e)
 
#define expect_data_available(a, b)   _expect_data_available(__LINE__,a,b)
 
#define async_query_data_available(a, b)   _async_query_data_available(__LINE__,a,b)
 
#define test_security_info(a, b, c)   _test_security_info(__LINE__,a,b,c)
 
#define test_secflags_option(a, b, c)   _test_secflags_option(__LINE__,a,b,c)
 
#define set_secflags(a, b, c)   _set_secflags(__LINE__,a,b,c)
 
#define STATUS_STRING(status)   status_string[status] = #status
 

Enumerations

enum  api {
  winhttp_connect = 1 , winhttp_open_request , winhttp_send_request , winhttp_receive_response ,
  winhttp_query_data , winhttp_read_data , winhttp_write_data , winhttp_close_handle ,
  internet_connect = 1 , http_open_request , http_send_request_ex , internet_writefile ,
  http_end_request , internet_close_handle
}
 

Functions

static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackA)(HINTERNET
 
static BOOL (WINAPI *pInternetGetSecurityInfoByURLA)(LPSTR
 
static PCCERT_CHAIN_CONTEXT DWORD *static BOOL is_lang_english (void)
 
static int strcmp_wa (LPCWSTR strw, const char *stra)
 
static BOOL proxy_active (void)
 
static void init_events (void)
 
static void free_events (void)
 
static void reset_events (void)
 
static void _test_status_code (unsigned line, HINTERNET req, DWORD excode, BOOL is_todo)
 
static void _test_request_flags (unsigned line, HINTERNET req, DWORD exflags, BOOL is_todo)
 
static void _test_request_url (unsigned line, HINTERNET req, const char *expected_url)
 
static void _test_http_version (unsigned line, HINTERNET req)
 
static VOID WINAPI callback (HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
 
static void _open_simple_request (unsigned line, test_request_t *req, const char *host, int port, const char *verb, const char *url)
 
static void _close_request (unsigned line, test_request_t *req)
 
static DWORD _receive_simple_request (unsigned line, HINTERNET req, char *buf, size_t buf_size)
 
static void close_async_handle (HINTERNET handle, int handle_cnt)
 
static void InternetReadFile_test (int flags, const test_data_t *test)
 
static void InternetReadFile_chunked_test (void)
 
static void InternetReadFileExA_test (int flags)
 
static void InternetOpenUrlA_test (void)
 
static void HttpSendRequestEx_test (void)
 
static void InternetOpenRequest_test (void)
 
static void test_cache_read (void)
 
static void test_http_cache (void)
 
static void InternetLockRequestFile_test (void)
 
static void HttpHeaders_test (void)
 
static DWORD CALLBACK server_thread (LPVOID param)
 
static void test_basic_request (int port, const char *verb, const char *url)
 
static void test_proxy_indirect (int port)
 
static void test_proxy_direct (int port)
 
static void test_header_handling_order (int port)
 
static void test_connection_header (int port)
 
static void test_header_override (int port)
 
static void test_connection_closing (int port)
 
static void test_successive_HttpSendRequest (int port)
 
static void test_no_content (int port)
 
static void test_conn_close (int port)
 
static void test_no_cache (int port)
 
static void test_cache_read_gzipped (int port)
 
static void test_HttpSendRequestW (int port)
 
static void test_cookie_header (int port)
 
static void test_basic_authentication (int port)
 
static void test_premature_disconnect (int port)
 
static void test_invalid_response_headers (int port)
 
static void test_response_without_headers (int port)
 
static void test_head_request (int port)
 
static void test_HttpQueryInfo (int port)
 
static void test_options (int port)
 
static void test_http_status (int port)
 
static void test_cache_control_verb (int port)
 
static void test_request_content_length (int port)
 
static void test_accept_encoding (int port)
 
static void test_basic_auth_credentials_reuse (int port)
 
static void test_basic_auth_credentials_end_session (int port)
 
static void test_basic_auth_credentials_different (int port)
 
static void test_basic_auth_credentials_manual (int port)
 
static void test_basic_auth_credentials_cached_manual (int port)
 
static void test_async_read (int port)
 
static void server_send_string (const char *msg)
 
static size_t server_read_data (char *buf, size_t buf_size)
 
static void _server_read_request (unsigned line, const char *expected_request)
 
static void WINAPI readex_callback (HINTERNET handle, DWORD_PTR context, DWORD status, void *info, DWORD info_size)
 
static void send_socket_request (test_request_t *req, BOOL new_connection)
 
static void open_socket_request (int port, test_request_t *req, const char *verb)
 
static void open_read_test_request (int port, test_request_t *req, const char *response)
 
static void _readex_expect_sync_data_len (unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, DWORD buf_size, const char *exdata, DWORD len, DWORD expect_receive)
 
static void _readex_expect_sync_data (unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, DWORD buf_size, const char *exdata, DWORD expect_receive)
 
static void _read_expect_sync_data_len (unsigned line, HINTERNET req, void *buf, DWORD buf_size, const char *exdata, DWORD len)
 
static void _read_expect_sync_data (unsigned line, HINTERNET req, void *buf, DWORD buf_size, const char *exdata)
 
static void close_connection (void)
 
static void _send_response_and_wait (unsigned line, const char *response, BOOL do_close_connection, void *buf, DWORD *ret_size, const char *exdata, DWORD expected_size, DWORD expected_req_error, DWORD expected_receive_size)
 
static void _send_response_ex_and_wait (unsigned line, const char *response, BOOL close_connection, INTERNET_BUFFERSW *buf, const char *exdata, DWORD expected_req_error, DWORD expected_receive_size)
 
static void send_response_len_and_wait (unsigned len, BOOL close_connection, INTERNET_BUFFERSW *buf)
 
static void _readex_expect_async (unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, DWORD buf_size, const char *exdata)
 
static void read_expect_async (HINTERNET req, void *buf, DWORD buf_size, DWORD *ret_size, const char *exdata)
 
static DWORD _expect_data_available (unsigned line, HINTERNET req, int exsize)
 
static void _async_query_data_available (unsigned line, HINTERNET req, DWORD *size)
 
static void test_http_read (int port)
 
static void test_connection_break (int port)
 
static void test_long_url (int port)
 
static void test_persistent_connection (int port)
 
static void test_redirect (int port)
 
static void test_remove_dot_segments (int port)
 
static void test_large_content (int port)
 
static void test_http_connection (void)
 
static void release_cert_info (INTERNET_CERTIFICATE_INFOA *info)
 
static void test_cert_struct_string (HINTERNET req, const INTERNET_CERTIFICATE_INFOA *info)
 
static void test_cert_struct (HINTERNET req, const cert_struct_test_t *test)
 
static void _test_security_info (unsigned line, const char *urlc, DWORD error, DWORD ex_flags)
 
static void _test_secflags_option (unsigned line, HINTERNET req, DWORD ex_flags, DWORD opt_flags)
 
static void _set_secflags (unsigned line, HINTERNET req, BOOL use_undoc, DWORD flags)
 
static void test_security_flags (void)
 
static void test_secure_connection (void)
 
static void test_user_agent_header (void)
 
static void test_bogus_accept_types_array (void)
 
static void WINAPI cb (HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID info, DWORD size)
 
static void test_open_url_async (void)
 
static void CALLBACK check_notification (HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID buffer, DWORD buflen)
 
static void setup_test (struct info *info, enum api function, unsigned int line, DWORD expect_result)
 
static void test_async_HttpSendRequestEx (const struct notification_data *nd)
 
static void WINAPI closetest_callback (HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
 
static void test_InternetCloseHandle (void)
 
static void test_connection_failure (void)
 
static void test_default_service_port (void)
 
static void init_status_tests (void)
 
static void WINAPI header_cb (HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID info, DWORD len)
 
static void test_concurrent_header_access (void)
 
static void test_cert_string (void)
 
 START_TEST (http)
 

Variables

static BOOL first_connection_to_test_url = TRUE
 
static BOOL https_support = TRUE
 
static int expect [MAX_INTERNET_STATUS]
 
static int optional [MAX_INTERNET_STATUS]
 
static int wine_allow [MAX_INTERNET_STATUS]
 
static int notified [MAX_INTERNET_STATUS]
 
static const charstatus_string [MAX_INTERNET_STATUS]
 
static HANDLE complete_event
 
static HANDLE conn_close_event
 
static HANDLE conn_wait_event
 
static HANDLE server_req_rec_event
 
static HANDLE request_sent_event
 
static DWORD req_error
 
static BOOL is_ie7plus = TRUE
 
static const test_data_t test_data []
 
static INTERNET_STATUS_CALLBACK
 
static int close_handle_cnt
 
static const char garbagemsg []
 
static const char contmsg []
 
static const char expandcontmsg []
 
static const char okmsg []
 
static const char okmsg201 []
 
static const char okmsg2 []
 
static DWORD64 content_length
 
static const char largemsg []
 
static const char okmsg_cookie_path []
 
static const char okmsg_cookie []
 
static const char notokmsg []
 
static const char noauthmsg []
 
static const char noauthmsg2 []
 
static const char proxymsg []
 
static const char page1 []
 
static const char ok_with_length []
 
static const char ok_with_length2 []
 
static int test_cache_gzip
 
static const charsend_buffer
 
static int server_socket
 
static const http_status_test_t http_status_tests []
 
static BOOL skip_receive_notification_tests
 
static DWORD received_response_size
 
static const cert_struct_test_t test_winehq_org_cert
 
static const cert_struct_test_t test_winehq_com_cert
 
static const charcert_string_fmt
 
static CRITICAL_SECTION notification_cs
 
static const struct notification async_send_request_ex_test []
 
static const struct notification async_send_request_ex_test2 []
 
static const struct notification async_send_request_ex_resolve_failure_test []
 
static const struct notification async_send_request_ex_chunked_test []
 
static const struct notification_data notification_data []
 
static HINTERNET closetest_session
 
static HINTERNET closetest_req
 
static HINTERNET closetest_conn
 
static BOOL closetest_closed
 

Macro Definition Documentation

◆ _SECURITY_FLAG_CERT_INVALID_CA

#define _SECURITY_FLAG_CERT_INVALID_CA   0x01000000

Definition at line 38 of file http.c.

◆ _SECURITY_FLAG_CERT_INVALID_CN

#define _SECURITY_FLAG_CERT_INVALID_CN   0x02000000

Definition at line 39 of file http.c.

◆ _SECURITY_FLAG_CERT_INVALID_DATE

#define _SECURITY_FLAG_CERT_INVALID_DATE   0x04000000

Definition at line 40 of file http.c.

◆ _SECURITY_FLAG_CERT_REV_FAILED

#define _SECURITY_FLAG_CERT_REV_FAILED   0x00800000

Definition at line 37 of file http.c.

◆ async_query_data_available

#define async_query_data_available (   a,
  b 
)    _async_query_data_available(__LINE__,a,b)

Definition at line 5703 of file http.c.

◆ CHECK_EXPECT

#define CHECK_EXPECT (   status)
Value:
do { \
{ \
todo_wine ok(expect[status], "unexpected status %d (%s)\n", status, \
status_string[status] : "unknown"); \
} \
else \
{ \
ok(expect[status] || optional[status], "unexpected status %d (%s)\n", status, \
status_string[status] : "unknown"); \
if (expect[status]) expect[status]--; \
else if(optional[status]) optional[status]--; \
} \
}while(0)
#define ok(value,...)
Definition: atltest.h:57
#define todo_wine
Definition: custom.c:79
static int optional[MAX_INTERNET_STATUS]
Definition: http.c:110
static int notified[MAX_INTERNET_STATUS]
Definition: http.c:111
#define MAX_INTERNET_STATUS
Definition: http.c:109
static const char * status_string[MAX_INTERNET_STATUS]
Definition: http.c:112
static int wine_allow[MAX_INTERNET_STATUS]
Definition: http.c:111
static int expect[MAX_INTERNET_STATUS]
Definition: http.c:110
Definition: ps.c:97

Definition at line 69 of file http.c.

◆ CHECK_NOT_NOTIFIED

#define CHECK_NOT_NOTIFIED (   status)     CHECK_NOTIFIED2(status, 0)

Definition at line 106 of file http.c.

◆ CHECK_NOTIFIED

#define CHECK_NOTIFIED (   status)     CHECK_NOTIFIED2(status, 1)

Definition at line 103 of file http.c.

◆ CHECK_NOTIFIED2

#define CHECK_NOTIFIED2 (   status,
  num 
)
Value:
do { \
"expected status %d (%s) %d times, received %d times\n", \
status_string[status] : "unknown", (num), notified[status]); \
CLEAR_NOTIFIED(status); \
}while(0)
GLuint GLuint num
Definition: glext.h:9618

Definition at line 94 of file http.c.

◆ CLEAR_NOTIFIED

#define CLEAR_NOTIFIED (   status)     expect[status] = optional[status] = wine_allow[status] = notified[status] = 0;

Definition at line 91 of file http.c.

◆ close_request

#define close_request (   a)    _close_request(__LINE__,a)

Definition at line 547 of file http.c.

◆ expect_data_available

#define expect_data_available (   a,
  b 
)    _expect_data_available(__LINE__,a,b)

Definition at line 5689 of file http.c.

◆ MAX_INTERNET_STATUS

#define MAX_INTERNET_STATUS   (INTERNET_STATUS_COOKIE_HISTORY+1)

Definition at line 109 of file http.c.

◆ open_simple_request

#define open_simple_request (   a,
  b,
  c,
  d,
  e 
)    _open_simple_request(__LINE__,a,b,c,d,e)

Definition at line 533 of file http.c.

◆ read_expect_sync_data

#define read_expect_sync_data (   a,
  b,
  c,
  d 
)    _read_expect_sync_data(__LINE__,a,b,c,d)

Definition at line 5569 of file http.c.

◆ read_expect_sync_data_len

#define read_expect_sync_data_len (   a,
  b,
  c,
  d,
  e 
)    _read_expect_sync_data_len(__LINE__,a,b,c,d,e)

Definition at line 5543 of file http.c.

◆ readex_expect_async

#define readex_expect_async (   a,
  b,
  c,
  d,
  e 
)    _readex_expect_async(__LINE__,a,b,c,d,e)

Definition at line 5638 of file http.c.

◆ readex_expect_sync_data

#define readex_expect_sync_data (   a,
  b,
  c,
  d,
  e,
  f 
)    _readex_expect_sync_data(__LINE__,a,b,c,d,e,f)

Definition at line 5536 of file http.c.

◆ readex_expect_sync_data_len

#define readex_expect_sync_data_len (   a,
  b,
  c,
  d,
  e,
  f,
  g 
)    _readex_expect_sync_data_len(__LINE__,a,b,c,d,e,f,g)

Definition at line 5509 of file http.c.

◆ receive_simple_request

#define receive_simple_request (   a,
  b,
  c 
)    _receive_simple_request(__LINE__,a,b,c)

Definition at line 560 of file http.c.

◆ send_response_and_wait

#define send_response_and_wait (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h 
)    _send_response_and_wait(__LINE__,a,b,c,d,e,f,g,h)

Definition at line 5583 of file http.c.

◆ send_response_ex_and_wait

#define send_response_ex_and_wait (   a,
  b,
  c,
  d,
  e,
  f 
)    _send_response_ex_and_wait(__LINE__,a,b,c,d,e,f)

Definition at line 5617 of file http.c.

◆ server_read_request

#define server_read_request (   a)    _server_read_request(__LINE__,a)

Definition at line 5388 of file http.c.

◆ SET_EXPECT

#define SET_EXPECT (   status)     SET_EXPECT2(status, 1)

Definition at line 52 of file http.c.

◆ SET_EXPECT2

#define SET_EXPECT2 (   status,
  num 
)     expect[status] = num

Definition at line 49 of file http.c.

◆ SET_OPTIONAL

#define SET_OPTIONAL (   status)     SET_OPTIONAL2(status, 1)

Definition at line 58 of file http.c.

◆ SET_OPTIONAL2

#define SET_OPTIONAL2 (   status,
  num 
)     optional[status] = num

Definition at line 55 of file http.c.

◆ set_secflags

#define set_secflags (   a,
  b,
  c 
)    _set_secflags(__LINE__,a,b,c)

Definition at line 6611 of file http.c.

◆ SET_WINE_ALLOW

#define SET_WINE_ALLOW (   status)     SET_WINE_ALLOW2(status, 1)

Definition at line 66 of file http.c.

◆ SET_WINE_ALLOW2

#define SET_WINE_ALLOW2 (   status,
  num 
)     wine_allow[status] = num

Definition at line 63 of file http.c.

◆ STATUS_STRING

#define STATUS_STRING (   status)    status_string[status] = #status

◆ test_http_version

#define test_http_version (   a)    _test_http_version(__LINE__,a)

Definition at line 352 of file http.c.

◆ test_request_flags

#define test_request_flags (   a,
  b 
)    _test_request_flags(__LINE__,a,b,FALSE)

Definition at line 321 of file http.c.

◆ test_request_flags_todo

#define test_request_flags_todo (   a,
  b 
)    _test_request_flags(__LINE__,a,b,TRUE)

Definition at line 322 of file http.c.

◆ test_request_url

#define test_request_url (   a,
  b 
)    _test_request_url(__LINE__,a,b)

Definition at line 339 of file http.c.

◆ test_secflags_option

#define test_secflags_option (   a,
  b,
  c 
)    _test_secflags_option(__LINE__,a,b,c)

Definition at line 6589 of file http.c.

◆ test_security_info

#define test_security_info (   a,
  b,
  c 
)    _test_security_info(__LINE__,a,b,c)

Definition at line 6549 of file http.c.

◆ test_status_code

#define test_status_code (   a,
  b 
)    _test_status_code(__LINE__,a,b, FALSE)

Definition at line 247 of file http.c.

◆ test_status_code_todo

#define test_status_code_todo (   a,
  b 
)    _test_status_code(__LINE__,a,b, TRUE)

Definition at line 248 of file http.c.

◆ TEST_URL

#define TEST_URL   "http://test.winehq.org/tests/hello.html"

Definition at line 42 of file http.c.

◆ TESTF_CHUNKED

#define TESTF_CHUNKED   0x04

Definition at line 120 of file http.c.

◆ TESTF_COMPRESSED

#define TESTF_COMPRESSED   0x02

Definition at line 119 of file http.c.

◆ TESTF_REDIRECT

#define TESTF_REDIRECT   0x01

Definition at line 118 of file http.c.

Enumeration Type Documentation

◆ api

Enumerator
winhttp_connect 
winhttp_open_request 
winhttp_send_request 
winhttp_receive_response 
winhttp_query_data 
winhttp_read_data 
winhttp_write_data 
winhttp_close_handle 
internet_connect 
http_open_request 
http_send_request_ex 
internet_writefile 
http_end_request 
internet_close_handle 

Definition at line 7354 of file http.c.

7355{
7356 internet_connect = 1,
7362};
@ http_send_request_ex
Definition: http.c:7358
@ internet_close_handle
Definition: http.c:7361
@ http_end_request
Definition: http.c:7360
@ internet_writefile
Definition: http.c:7359
@ http_open_request
Definition: http.c:7357
@ internet_connect
Definition: http.c:7356

Function Documentation

◆ _async_query_data_available()

static void _async_query_data_available ( unsigned  line,
HINTERNET  req,
DWORD size 
)
static

Definition at line 5704 of file http.c.

5705{
5706 BOOL res;
5707
5710
5711 *size = 0xdeadbeef;
5712 res = InternetQueryDataAvailable(req, size, 0, 0);
5713 ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING,
5714 "InternetQueryDataAvailable returned: %x(%u)\n", res, GetLastError());
5715 ok_(__FILE__,line)(!*size, "size = %u\n", *size);
5716
5719}
#define ok_(x1, x2)
Definition: atltest.h:61
#define ERROR_IO_PENDING
Definition: dderror.h:15
BOOL WINAPI InternetQueryDataAvailable(HINTERNET hFile, LPDWORD lpdwNumberOfBytesAvailable, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3959
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
#define CHECK_NOTIFIED(status)
Definition: http.c:103
static BOOL skip_receive_notification_tests
Definition: http.c:5401
#define SET_EXPECT(status)
Definition: http.c:52
Definition: parser.c:49
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define INTERNET_STATUS_RECEIVING_RESPONSE
Definition: wininet.h:889

◆ _close_request()

static void _close_request ( unsigned  line,
test_request_t req 
)
static

Definition at line 548 of file http.c.

549{
550 BOOL ret;
551
553 ok_(__FILE__,line)(ret, "InternetCloseHandle(request) failed: %u\n", GetLastError());
555 ok_(__FILE__,line)(ret, "InternetCloseHandle(connection) failed: %u\n", GetLastError());
557 ok_(__FILE__,line)(ret, "InternetCloseHandle(session) failed: %u\n", GetLastError());
558}
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1414
HINTERNET connection
Definition: http.c:529
HINTERNET session
Definition: http.c:528
HINTERNET request
Definition: http.c:530
int ret

◆ _expect_data_available()

static DWORD _expect_data_available ( unsigned  line,
HINTERNET  req,
int  exsize 
)
static

Definition at line 5690 of file http.c.

5691{
5692 DWORD size = 0;
5693 BOOL res;
5694
5695 res = InternetQueryDataAvailable(req, &size, 0, 0);
5696 ok_(__FILE__,line)(res, "InternetQueryDataAvailable failed: %u\n", GetLastError());
5697 if(exsize != -1)
5698 ok_(__FILE__,line)(size == exsize, "size = %u, expected %u\n", size, exsize);
5699
5700 return size;
5701}
unsigned long DWORD
Definition: ntddk_ex.h:95

◆ _open_simple_request()

static void _open_simple_request ( unsigned  line,
test_request_t req,
const char host,
int  port,
const char verb,
const char url 
)
static

Definition at line 534 of file http.c.

536{
538 ok_(__FILE__,line)(req->session != NULL, "InternetOpenA failed: %u\n", GetLastError());
539
541 ok_(__FILE__,line)(req->connection != NULL, "InternetConnectA failed: %u\n", GetLastError());
542
543 req->request = HttpOpenRequestA(req->connection, verb, url, NULL, NULL, NULL, 0, 0);
544 ok_(__FILE__,line)(req->request != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
545}
#define NULL
Definition: types.h:112
USHORT port
Definition: uri.c:228
HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession, LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion, LPCSTR lpszReferrer, LPCSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:1410
HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:1057
HINTERNET WINAPI InternetConnectA(HINTERNET hInternet, LPCSTR lpszServerName, INTERNET_PORT nServerPort, LPCSTR lpszUserName, LPCSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1321
static const WCHAR url[]
Definition: encode.c:1432
char * host
Definition: whois.c:55
#define INTERNET_OPEN_TYPE_DIRECT
Definition: wininet.h:522
#define INTERNET_SERVICE_HTTP
Definition: wininet.h:562

◆ _read_expect_sync_data()

static void _read_expect_sync_data ( unsigned  line,
HINTERNET  req,
void buf,
DWORD  buf_size,
const char exdata 
)
static

Definition at line 5570 of file http.c.

5572{
5573 _read_expect_sync_data_len(line, req, buf, buf_size, exdata, strlen(exdata));
5574}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static void _read_expect_sync_data_len(unsigned line, HINTERNET req, void *buf, DWORD buf_size, const char *exdata, DWORD len)
Definition: http.c:5544

◆ _read_expect_sync_data_len()

static void _read_expect_sync_data_len ( unsigned  line,
HINTERNET  req,
void buf,
DWORD  buf_size,
const char exdata,
DWORD  len 
)
static

Definition at line 5544 of file http.c.

5546{
5547 DWORD ret_size = 0xdeadbeef;
5548 BOOL ret;
5549
5553 received_response_size = 0xdeadbeef;
5554
5555 memset(buf, 0xff, buf_size);
5556 ret = InternetReadFile(req, buf, buf_size, &ret_size);
5557 ok_(__FILE__,line)(ret, "InternetReadFileExW failed: %u\n", GetLastError());
5558 ok_(__FILE__,line)(ret_size == len, "dwBufferLength = %u, expected %u\n", ret_size, len);
5559 if(len && exdata)
5560 ok_(__FILE__,line)(!memcmp(buf, exdata, len), "Unexpected data\n");
5561
5565 ok_(__FILE__,line)(received_response_size == len, "received_response_size = %u\n", received_response_size);
5566 ok_(__FILE__,line)(!req_error, "req_error = %u\n", req_error);
5567}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer, DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
Definition: internet.c:2154
GLenum GLsizei len
Definition: glext.h:6722
static DWORD req_error
Definition: http.c:115
#define CLEAR_NOTIFIED(status)
Definition: http.c:91
static DWORD received_response_size
Definition: http.c:5402
#define memset(x, y, z)
Definition: compat.h:39
#define INTERNET_STATUS_RESPONSE_RECEIVED
Definition: wininet.h:890
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898

Referenced by _read_expect_sync_data().

◆ _readex_expect_async()

static void _readex_expect_async ( unsigned  line,
HINTERNET  req,
DWORD  flags,
INTERNET_BUFFERSW buf,
DWORD  buf_size,
const char exdata 
)
static

Definition at line 5639 of file http.c.

5641{
5642 unsigned len = 0;
5643 BOOL ret;
5644
5647
5648 memset(buf->lpvBuffer, 0, max(buf_size, sizeof(DWORD)));
5649 buf->dwBufferLength = buf_size;
5650 ret = InternetReadFileExW(req, buf, flags, 0xdeadbeef);
5651 ok_(__FILE__,line)(!ret && GetLastError() == ERROR_IO_PENDING, "InternetReadFileExW returned %x (%u)\n", ret, GetLastError());
5652 ok_(__FILE__,line)(buf->dwBufferLength == buf_size, "dwBufferLength = %u, expected %u\n", buf->dwBufferLength, buf_size);
5653 if(exdata) {
5654 len = strlen(exdata);
5655 ok_(__FILE__,line)(!memcmp(buf->lpvBuffer, exdata, len), "unexpected buffer data\n");
5656 }else {
5657 ok_(__FILE__,line)(!*(DWORD*)buf->lpvBuffer, "buffer data changed\n");
5658 }
5659
5662}
BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:2248
GLbitfield flags
Definition: glext.h:7161
#define max(a, b)
Definition: svc.c:63

◆ _readex_expect_sync_data()

static void _readex_expect_sync_data ( unsigned  line,
HINTERNET  req,
DWORD  flags,
INTERNET_BUFFERSW buf,
DWORD  buf_size,
const char exdata,
DWORD  expect_receive 
)
static

Definition at line 5537 of file http.c.

5539{
5540 _readex_expect_sync_data_len(line, req, flags, buf, buf_size, exdata, strlen(exdata), expect_receive);
5541}
static void _readex_expect_sync_data_len(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, DWORD buf_size, const char *exdata, DWORD len, DWORD expect_receive)
Definition: http.c:5510

◆ _readex_expect_sync_data_len()

static void _readex_expect_sync_data_len ( unsigned  line,
HINTERNET  req,
DWORD  flags,
INTERNET_BUFFERSW buf,
DWORD  buf_size,
const char exdata,
DWORD  len,
DWORD  expect_receive 
)
static

Definition at line 5510 of file http.c.

5512{
5513 BOOL ret;
5514
5515 if(!skip_receive_notification_tests && expect_receive) {
5518 received_response_size = 0xdeadbeef;
5519 }
5520
5521 memset(buf->lpvBuffer, 0xff, buf_size);
5522 buf->dwBufferLength = buf_size;
5523 ret = InternetReadFileExW(req, buf, flags, 0xdeadbeef);
5524 ok_(__FILE__,line)(ret, "InternetReadFileExW failed: %u\n", GetLastError());
5525 ok_(__FILE__,line)(buf->dwBufferLength == len, "dwBufferLength = %u, expected %u\n", buf->dwBufferLength, len);
5526 if(len && exdata)
5527 ok_(__FILE__,line)(!memcmp(buf->lpvBuffer, exdata, len), "Unexpected data\n");
5528
5529 if(!skip_receive_notification_tests && expect_receive) {
5532 ok_(__FILE__,line)(received_response_size == len, "received_response_size = %u\n", received_response_size);
5533 }
5534}

Referenced by _readex_expect_sync_data().

◆ _receive_simple_request()

static DWORD _receive_simple_request ( unsigned  line,
HINTERNET  req,
char buf,
size_t  buf_size 
)
static

Definition at line 561 of file http.c.

562{
563 DWORD read = 0;
564 BOOL ret;
565
566 ret = InternetReadFile(req, buf, buf_size, &read);
567 ok_(__FILE__,line)(ret, "InternetReadFile failed: %u\n", GetLastError());
568
569 return read;
570}
#define read
Definition: acwin.h:96

◆ _send_response_and_wait()

static void _send_response_and_wait ( unsigned  line,
const char response,
BOOL  do_close_connection,
void buf,
DWORD ret_size,
const char exdata,
DWORD  expected_size,
DWORD  expected_req_error,
DWORD  expected_receive_size 
)
static

Definition at line 5584 of file http.c.

5587{
5591
5592 if(response)
5593 server_send_string(response);
5594
5595 if(do_close_connection)
5597
5599
5603 if(!skip_receive_notification_tests && expected_receive_size != -1)
5604 todo_wine_if(received_response_size != expected_receive_size) /* FIXME! remove when wine is fixed */
5605 ok_(__FILE__,line)(received_response_size == expected_receive_size,
5606 "received_response_size = %u\n", received_response_size);
5607 ok_(__FILE__,line)(req_error == expected_req_error, "req_error = %u, expected %u\n", req_error, expected_req_error);
5608
5609 /* If IRF_NO_WAIT is used, buffer is not changed. */
5610 ok_(__FILE__,line)(*ret_size == expected_size, "dwBufferLength = %u\n", *ret_size);
5611 if(exdata)
5612 ok_(__FILE__,line)(!memcmp(buf, exdata, strlen(exdata)), "unexpected buffer data\n");
5613 else if(buf)
5614 ok_(__FILE__,line)(!*(DWORD*)buf, "buffer data changed\n");
5615}
#define INFINITE
Definition: serial.h:102
#define todo_wine_if(is_todo)
Definition: custom.c:76
static void server_send_string(const char *msg)
Definition: http.c:5378
static HANDLE complete_event
Definition: http.c:114
static void close_connection(void)
Definition: http.c:5576
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82

Referenced by _send_response_ex_and_wait().

◆ _send_response_ex_and_wait()

static void _send_response_ex_and_wait ( unsigned  line,
const char response,
BOOL  close_connection,
INTERNET_BUFFERSW buf,
const char exdata,
DWORD  expected_req_error,
DWORD  expected_receive_size 
)
static

Definition at line 5618 of file http.c.

5621{
5622 _send_response_and_wait(line, response, close_connection, buf->lpvBuffer, &buf->dwBufferLength,
5623 exdata, exdata ? strlen(exdata) : buf->dwBufferLength, expected_req_error,
5624 expected_receive_size);
5625}
static void _send_response_and_wait(unsigned line, const char *response, BOOL do_close_connection, void *buf, DWORD *ret_size, const char *exdata, DWORD expected_size, DWORD expected_req_error, DWORD expected_receive_size)
Definition: http.c:5584

◆ _server_read_request()

static void _server_read_request ( unsigned  line,
const char expected_request 
)
static

Definition at line 5389 of file http.c.

5390{
5391 char buf[4000], *p;
5392 size_t size;
5393
5394 size = server_read_data(buf, sizeof(buf) - 1);
5395 buf[size] = 0;
5396 p = strstr(buf, "\r\n");
5397 if(p) *p = 0;
5398 ok_(__FILE__,line)(p && !strcmp(buf, expected_request), "unexpected request %s\n", buf);
5399}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
GLfloat GLfloat p
Definition: glext.h:8902
#define server_read_data(a)
Definition: notification.c:843

◆ _set_secflags()

static void _set_secflags ( unsigned  line,
HINTERNET  req,
BOOL  use_undoc,
DWORD  flags 
)
static

Definition at line 6612 of file http.c.

6613{
6614 BOOL res;
6615
6616 res = InternetSetOptionW(req, use_undoc ? 99 : INTERNET_OPTION_SECURITY_FLAGS, &flags, sizeof(flags));
6617 ok_(__FILE__,line)(res, "InternetSetOption(INTERNET_OPTION_SECURITY_FLAGS) failed: %u\n", GetLastError());
6618}
BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:2837
#define INTERNET_OPTION_SECURITY_FLAGS
Definition: wininet.h:725

◆ _test_http_version()

static void _test_http_version ( unsigned  line,
HINTERNET  req 
)
static

Definition at line 353 of file http.c.

354{
355 HTTP_VERSION_INFO v = {0xdeadbeef, 0xdeadbeef};
356 DWORD size;
357 BOOL res;
358
359 size = sizeof(v);
361 ok_(__FILE__,line)(res, "InternetQueryOptionW(INTERNET_OPTION_HTTP_VERSION) failed: %u\n", GetLastError());
362 ok_(__FILE__,line)(v.dwMajorVersion == 1, "dwMajorVersion = %d\n", v.dwMajorVersion);
363 ok_(__FILE__,line)(v.dwMinorVersion == 1, "dwMinorVersion = %d\n", v.dwMinorVersion);
364}
BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength)
Definition: internet.c:2697
const GLdouble * v
Definition: gl.h:2040
#define INTERNET_OPTION_HTTP_VERSION
Definition: wininet.h:753

◆ _test_request_flags()

static void _test_request_flags ( unsigned  line,
HINTERNET  req,
DWORD  exflags,
BOOL  is_todo 
)
static

Definition at line 323 of file http.c.

324{
326 BOOL res;
327
328 flags = 0xdeadbeef;
329 size = sizeof(flags);
331 ok_(__FILE__,line)(res, "InternetQueryOptionW(INTERNET_OPTION_REQUEST_FLAGS) failed: %u\n", GetLastError());
332
333 /* FIXME: Remove once we have INTERNET_REQFLAG_CACHE_WRITE_DISABLED implementation */
334 flags &= ~INTERNET_REQFLAG_CACHE_WRITE_DISABLED;
335 todo_wine_if (is_todo)
336 ok_(__FILE__,line)(flags == exflags, "flags = %x, expected %x\n", flags, exflags);
337}
#define INTERNET_OPTION_REQUEST_FLAGS
Definition: wininet.h:718

◆ _test_request_url()

static void _test_request_url ( unsigned  line,
HINTERNET  req,
const char expected_url 
)
static

Definition at line 340 of file http.c.

341{
343 DWORD size = sizeof(buf);
344 BOOL res;
345
347 ok_(__FILE__,line)(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
348 ok_(__FILE__,line)(size == strlen(expected_url), "size = %u\n", size);
349 ok_(__FILE__,line)(!strcmp(buf, expected_url), "unexpected URL %s, expected %s\n", buf, expected_url);
350}
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1418
BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength)
Definition: internet.c:2730
#define INTERNET_OPTION_URL
Definition: wininet.h:728

◆ _test_secflags_option()

static void _test_secflags_option ( unsigned  line,
HINTERNET  req,
DWORD  ex_flags,
DWORD  opt_flags 
)
static

Definition at line 6590 of file http.c.

6591{
6592 DWORD flags, size;
6593 BOOL res;
6594
6595 flags = 0xdeadbeef;
6596 size = sizeof(flags);
6598 ok_(__FILE__,line)(res, "InternetQueryOptionW(INTERNET_OPTION_SECURITY_FLAGS) failed: %u\n", GetLastError());
6599 ok_(__FILE__,line)((flags & ~opt_flags) == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS flags = %x, expected %x\n",
6600 flags, ex_flags);
6601
6602 /* Option 98 is undocumented and seems to be the same as INTERNET_OPTION_SECURITY_FLAGS */
6603 flags = 0xdeadbeef;
6604 size = sizeof(flags);
6605 res = InternetQueryOptionW(req, 98, &flags, &size);
6606 ok_(__FILE__,line)(res, "InternetQueryOptionW(98) failed: %u\n", GetLastError());
6607 ok_(__FILE__,line)((flags & ~opt_flags) == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS(98) flags = %x, expected %x\n",
6608 flags, ex_flags);
6609}

◆ _test_security_info()

static void _test_security_info ( unsigned  line,
const char urlc,
DWORD  error,
DWORD  ex_flags 
)
static

Definition at line 6550 of file http.c.

6551{
6554 DWORD flags;
6555 BOOL res;
6556
6557 if(!pInternetGetSecurityInfoByURLA) {
6558 win_skip("pInternetGetSecurityInfoByURLA not available\n");
6559 return;
6560 }
6561
6562 strcpy(url, urlc);
6563 chain = (void*)0xdeadbeef;
6564 flags = 0xdeadbeef;
6565 res = pInternetGetSecurityInfoByURLA(url, &chain, &flags);
6566 if(error == ERROR_SUCCESS) {
6567 ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %u\n", GetLastError());
6568 ok_(__FILE__,line)(chain != NULL, "chain = NULL\n");
6569 ok_(__FILE__,line)(flags == ex_flags, "flags = %x\n", flags);
6571
6572 SetLastError(0xdeadbeef);
6573 res = pInternetGetSecurityInfoByURLA(url, NULL, NULL);
6574 ok_(__FILE__,line)(!res && GetLastError() == ERROR_INVALID_PARAMETER,
6575 "InternetGetSecurityInfoByURLA returned: %x(%u)\n", res, GetLastError());
6576
6577 res = pInternetGetSecurityInfoByURLA(url, &chain, NULL);
6578 ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %u\n", GetLastError());
6580
6581 res = pInternetGetSecurityInfoByURLA(url, NULL, &flags);
6582 ok_(__FILE__,line)(res, "InternetGetSecurityInfoByURLA failed: %u\n", GetLastError());
6583 }else {
6584 ok_(__FILE__,line)(!res && GetLastError() == error,
6585 "InternetGetSecurityInfoByURLA returned: %x(%u), expected %u\n", res, GetLastError(), error);
6586 }
6587}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define ERROR_SUCCESS
Definition: deptool.c:10
VOID WINAPI CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT pChainContext)
Definition: chain.c:2960
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define error(str)
Definition: mkdosfs.c:1605
#define win_skip
Definition: test.h:160
struct sock * chain
Definition: tcpcore.h:1

◆ _test_status_code()

static void _test_status_code ( unsigned  line,
HINTERNET  req,
DWORD  excode,
BOOL  is_todo 
)
static

Definition at line 249 of file http.c.

250{
252 char exbuf[12], bufa[10];
253 WCHAR bufw[10];
254 BOOL res;
255
256 code = 0xdeadbeef;
257 size = sizeof(code);
259 ok_(__FILE__,line)(res, "[1] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE|number) failed: %u\n", GetLastError());
260 todo_wine_if (is_todo)
261 ok_(__FILE__,line)(code == excode, "code = %d, expected %d\n", code, excode);
262 ok_(__FILE__,line)(size == sizeof(code), "size = %u\n", size);
263
264 code = 0xdeadbeef;
265 index = 0;
266 size = sizeof(code);
268 ok_(__FILE__,line)(res, "[2] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE|number index) failed: %u\n", GetLastError());
269 ok_(__FILE__,line)(!index, "index = %d, expected 0\n", index);
270 ok_(__FILE__,line)(size == sizeof(code), "size = %u\n", size);
271
272 sprintf(exbuf, "%u", excode);
273
274 size = sizeof(bufa);
276 ok_(__FILE__,line)(res, "[3] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE) failed: %u\n", GetLastError());
277 todo_wine_if (is_todo)
278 ok_(__FILE__,line)(!strcmp(bufa, exbuf), "unexpected status code %s, expected %s\n", bufa, exbuf);
279 ok_(__FILE__,line)(size == strlen(exbuf), "unexpected size %d for \"%s\"\n", size, exbuf);
280
281 size = 0;
284 "[4] HttpQueryInfoA(HTTP_QUERY_STATUS_CODE) failed: %u\n", GetLastError());
285 ok_(__FILE__,line)(size == strlen(exbuf)+1, "unexpected size %d for \"%s\"\n", size, exbuf);
286
287 size = sizeof(bufw);
289 ok_(__FILE__,line)(res, "[5] HttpQueryInfoW(HTTP_QUERY_STATUS_CODE) failed: %u\n", GetLastError());
290 todo_wine_if (is_todo)
291 ok_(__FILE__,line)(!strcmp_wa(bufw, exbuf), "unexpected status code %s, expected %s\n", bufa, exbuf);
292 ok_(__FILE__,line)(size == strlen(exbuf)*sizeof(WCHAR), "unexpected size %d for \"%s\"\n", size, exbuf);
293
294 size = 0;
297 "[6] HttpQueryInfoW(HTTP_QUERY_STATUS_CODE) failed: %u\n", GetLastError());
298 ok_(__FILE__,line)(size == (strlen(exbuf)+1)*sizeof(WCHAR), "unexpected size %d for \"%s\"\n", size, exbuf);
299
300 if(0) {
301 size = sizeof(bufw);
303 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER, "HttpQueryInfo(HTTP_QUERY_STATUS_CODE) failed: %u\n", GetLastError());
304 ok(size == sizeof(bufw), "unexpected size %d\n", size);
305 }
306
307 code = 0xdeadbeef;
308 index = 1;
309 size = sizeof(code);
312 "[7] HttpQueryInfoA failed: %x(%d)\n", res, GetLastError());
313
314 code = 0xdeadbeef;
315 size = sizeof(code);
318 "[8] HttpQueryInfoA failed: %x(%d)\n", res, GetLastError());
319}
#define index(s, c)
Definition: various.h:29
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:4018
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3870
GLuint index
Definition: glext.h:6031
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static int strcmp_wa(LPCWSTR strw, const char *stra)
Definition: http.c:194
Definition: inflate.c:139
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
#define HTTP_QUERY_STATUS_CODE
Definition: wininet.h:1542
#define ERROR_HTTP_INVALID_QUERY_REQUEST
Definition: wininet.h:2062
#define HTTP_QUERY_FLAG_REQUEST_HEADERS
Definition: wininet.h:1604
#define ERROR_HTTP_HEADER_NOT_FOUND
Definition: wininet.h:2058
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ BOOL()

static BOOL ( WINAPI pInternetGetSecurityInfoByURLA)
static

◆ callback()

static VOID WINAPI callback ( HINTERNET  hInternet,
DWORD_PTR  dwContext,
DWORD  dwInternetStatus,
LPVOID  lpvStatusInformation,
DWORD  dwStatusInformationLength 
)
static

Definition at line 368 of file http.c.

375{
377 CHECK_EXPECT(dwInternetStatus);
378 switch (dwInternetStatus)
379 {
381 if(winetest_debug > 1)
382 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RESOLVING_NAME \"%s\" %d\n",
383 GetCurrentThreadId(), hInternet, dwContext,
384 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
385 *(LPSTR)lpvStatusInformation = '\0';
386 break;
388 if(winetest_debug > 1)
389 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_NAME_RESOLVED \"%s\" %d\n",
390 GetCurrentThreadId(), hInternet, dwContext,
391 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
392 *(LPSTR)lpvStatusInformation = '\0';
393 break;
395 if(winetest_debug > 1)
396 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %d\n",
397 GetCurrentThreadId(), hInternet, dwContext,
398 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
399 ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %u\n",
400 dwStatusInformationLength);
401 *(LPSTR)lpvStatusInformation = '\0';
402 break;
404 if(winetest_debug > 1)
405 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %d\n",
406 GetCurrentThreadId(), hInternet, dwContext,
407 (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
408 ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %u\n",
409 dwStatusInformationLength);
410 *(LPSTR)lpvStatusInformation = '\0';
411 break;
413 if(winetest_debug > 1)
414 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_SENDING_REQUEST %p %d\n",
415 GetCurrentThreadId(), hInternet, dwContext,
416 lpvStatusInformation,dwStatusInformationLength);
417 break;
419 ok(dwStatusInformationLength == sizeof(DWORD),
420 "info length should be sizeof(DWORD) instead of %d\n",
421 dwStatusInformationLength);
422 if(winetest_debug > 1)
423 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_SENT 0x%x %d\n",
424 GetCurrentThreadId(), hInternet, dwContext,
425 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
426 break;
428 if(winetest_debug > 1)
429 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RECEIVING_RESPONSE %p %d\n",
430 GetCurrentThreadId(), hInternet, dwContext,
431 lpvStatusInformation,dwStatusInformationLength);
432 break;
434 ok(dwStatusInformationLength == sizeof(DWORD),
435 "info length should be sizeof(DWORD) instead of %d\n",
436 dwStatusInformationLength);
437 if(winetest_debug > 1)
438 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RESPONSE_RECEIVED 0x%x %d\n",
439 GetCurrentThreadId(), hInternet, dwContext,
440 *(DWORD *)lpvStatusInformation,dwStatusInformationLength);
441 break;
443 if(winetest_debug > 1)
444 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CTL_RESPONSE_RECEIVED %p %d\n",
445 GetCurrentThreadId(), hInternet,dwContext,
446 lpvStatusInformation,dwStatusInformationLength);
447 break;
449 if(winetest_debug > 1)
450 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_PREFETCH %p %d\n",
451 GetCurrentThreadId(), hInternet, dwContext,
452 lpvStatusInformation,dwStatusInformationLength);
453 break;
455 if(winetest_debug > 1)
456 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CLOSING_CONNECTION %p %d\n",
457 GetCurrentThreadId(), hInternet, dwContext,
458 lpvStatusInformation,dwStatusInformationLength);
459 break;
461 if(winetest_debug > 1)
462 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTION_CLOSED %p %d\n",
463 GetCurrentThreadId(), hInternet, dwContext,
464 lpvStatusInformation,dwStatusInformationLength);
465 break;
467 ok(dwStatusInformationLength == sizeof(HINTERNET),
468 "info length should be sizeof(HINTERNET) instead of %d\n",
469 dwStatusInformationLength);
470 if(winetest_debug > 1)
471 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CREATED %p %d\n",
472 GetCurrentThreadId(), hInternet, dwContext,
473 *(HINTERNET *)lpvStatusInformation,dwStatusInformationLength);
476 break;
478 ok(dwStatusInformationLength == sizeof(HINTERNET),
479 "info length should be sizeof(HINTERNET) instead of %d\n",
480 dwStatusInformationLength);
481 if(winetest_debug > 1)
482 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CLOSING %p %d\n",
483 GetCurrentThreadId(), hInternet, dwContext,
484 *(HINTERNET *)lpvStatusInformation, dwStatusInformationLength);
487 break;
489 {
490 INTERNET_ASYNC_RESULT *iar = (INTERNET_ASYNC_RESULT *)lpvStatusInformation;
491 ok(dwStatusInformationLength == sizeof(INTERNET_ASYNC_RESULT),
492 "info length should be sizeof(INTERNET_ASYNC_RESULT) instead of %d\n",
493 dwStatusInformationLength);
494 ok(iar->dwResult == 1 || iar->dwResult == 0, "iar->dwResult = %ld\n", iar->dwResult);
495 if(winetest_debug > 1)
496 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_COMPLETE {%ld,%d} %d\n",
497 GetCurrentThreadId(), hInternet, dwContext,
498 iar->dwResult,iar->dwError,dwStatusInformationLength);
499 req_error = iar->dwError;
502 break;
503 }
505 if(winetest_debug > 1)
506 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REDIRECT \"%s\" %d\n",
507 GetCurrentThreadId(), hInternet, dwContext,
508 (LPCSTR)lpvStatusInformation, dwStatusInformationLength);
509 *(LPSTR)lpvStatusInformation = '\0';
512 break;
514 if(winetest_debug > 1)
515 trace("%04x:Callback %p 0x%lx INTERNET_STATUS_INTERMEDIATE_RESPONSE %p %d\n",
516 GetCurrentThreadId(), hInternet, dwContext,
517 lpvStatusInformation, dwStatusInformationLength);
518 break;
519 default:
520 if(winetest_debug > 1)
521 trace("%04x:Callback %p 0x%lx %d %p %d\n",
522 GetCurrentThreadId(), hInternet, dwContext, dwInternetStatus,
523 lpvStatusInformation, dwStatusInformationLength);
524 }
525}
#define InterlockedDecrement
Definition: armddk.h:52
#define trace
Definition: atltest.h:70
#define CHECK_EXPECT(status)
Definition: http.c:69
static int close_handle_cnt
Definition: http.c:366
int winetest_debug
#define ros_skip_flaky
Definition: test.h:177
DWORD_PTR dwResult
Definition: wininet.h:155
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define INTERNET_STATUS_CONNECTION_CLOSED
Definition: wininet.h:894
#define INTERNET_STATUS_REQUEST_SENT
Definition: wininet.h:888
#define INTERNET_STATUS_SENDING_REQUEST
Definition: wininet.h:887
#define INTERNET_STATUS_PREFETCH
Definition: wininet.h:892
#define INTERNET_STATUS_HANDLE_CLOSING
Definition: wininet.h:896
#define INTERNET_STATUS_RESOLVING_NAME
Definition: wininet.h:883
#define INTERNET_STATUS_INTERMEDIATE_RESPONSE
Definition: wininet.h:900
#define INTERNET_STATUS_REDIRECT
Definition: wininet.h:899
#define INTERNET_STATUS_CONNECTING_TO_SERVER
Definition: wininet.h:885
#define INTERNET_STATUS_HANDLE_CREATED
Definition: wininet.h:895
#define INTERNET_STATUS_CONNECTED_TO_SERVER
Definition: wininet.h:886
#define INTERNET_STATUS_NAME_RESOLVED
Definition: wininet.h:884
#define INTERNET_STATUS_CTL_RESPONSE_RECEIVED
Definition: wininet.h:891
#define INTERNET_STATUS_CLOSING_CONNECTION
Definition: wininet.h:893
#define INTERNET_STATUS_DETECTING_PROXY
Definition: wininet.h:897
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182

◆ cb()

static void WINAPI cb ( HINTERNET  handle,
DWORD_PTR  context,
DWORD  status,
LPVOID  info,
DWORD  size 
)
static

Definition at line 7257 of file http.c.

7258{
7260 struct context *ctx = (struct context *)context;
7261
7262 if(winetest_debug > 1)
7263 trace("%p 0x%08lx %u %p 0x%08x\n", handle, context, status, info, size);
7264
7265 switch(status) {
7267 trace("request handle: 0x%08lx\n", result->dwResult);
7268 ctx->req = (HINTERNET)result->dwResult;
7269 SetEvent(ctx->event);
7270 break;
7273
7275 ok(type != INTERNET_HANDLE_TYPE_CONNECT_HTTP, "unexpected callback\n");
7276 SetEvent(ctx->event);
7277 break;
7278 }
7282 char *str = info;
7283 ok(str[0] && str[1], "Got string: %s\n", str);
7284 ok(size == strlen(str)+1, "unexpected size %u\n", size);
7285 }
7286 }
7287}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
const WCHAR * str
Definition: http.c:7252
LPVOID HINTERNET
Definition: winhttp.h:32
#define INTERNET_HANDLE_TYPE_CONNECT_HTTP
Definition: wininet.h:805
#define INTERNET_OPTION_HANDLE_TYPE
Definition: wininet.h:710

◆ check_notification()

static void CALLBACK check_notification ( HINTERNET  handle,
DWORD_PTR  context,
DWORD  status,
LPVOID  buffer,
DWORD  buflen 
)
static

Definition at line 7388 of file http.c.

7389{
7390 BOOL status_ok, function_ok;
7391 struct info *info = (struct info *)context;
7392 unsigned int i;
7393
7395
7396 if(info->is_aborted) {
7398 return;
7399 }
7400
7402 {
7403 DWORD size = sizeof(struct info *);
7407
7408 ok(buflen == sizeof(*ar), "unexpected buflen = %d\n", buflen);
7410 ok(ar->dwResult == 1, "ar->dwResult = %ld, expected 1\n", ar->dwResult);
7411 }else {
7412 ok(!ar->dwResult, "ar->dwResult = %ld, expected 1\n", ar->dwResult);
7413 ok(ar->dwError == info->expect_result, "ar->dwError = %d, expected %d\n", ar->dwError, info->expect_result);
7414 }
7415 }
7416
7417 i = info->index;
7418 if (i >= info->count)
7419 {
7421 return;
7422 }
7423
7424 while (info->test[i].status != status &&
7425 (info->test[i].optional || info->test[i].todo) &&
7426 i < info->count - 1 &&
7427 info->test[i].function == info->test[i + 1].function)
7428 {
7429 i++;
7430 }
7431
7432 status_ok = (info->test[i].status == status);
7433 function_ok = (info->test[i].function == info->function);
7434
7435 if (!info->test[i].todo)
7436 {
7437 ok( status_ok, "%u: expected status %u got %u\n", info->line, info->test[i].status, status );
7438 ok( function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function );
7439
7440 if (info->test[i].async)
7441 ok(info->thread != GetCurrentThreadId(), "%u: expected thread %u got %u\n",
7443 }
7444 else
7445 {
7446 todo_wine ok( status_ok, "%u: expected status %u got %u\n", info->line, info->test[i].status, status );
7447 if (status_ok)
7448 todo_wine ok( function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function );
7449 }
7450 if (i == info->count - 1 || info->test[i].function != info->test[i + 1].function) SetEvent( info->wait );
7451 info->index = i+1;
7452
7454}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
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 CRITICAL_SECTION notification_cs
Definition: http.c:7386
unsigned int line
Definition: notification.c:67
enum api function
Definition: notification.c:62
unsigned int index
Definition: notification.c:65
BOOL is_aborted
Definition: http.c:7383
DWORD expect_result
Definition: http.c:7382
const struct notification * test
Definition: notification.c:63
DWORD thread
Definition: http.c:7380
HANDLE wait
Definition: notification.c:66
unsigned int count
Definition: notification.c:64
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define INTERNET_OPTION_CONTEXT_VALUE
Definition: wininet.h:739

Referenced by test_async_HttpSendRequestEx().

◆ close_async_handle()

static void close_async_handle ( HINTERNET  handle,
int  handle_cnt 
)
static

◆ close_connection()

static void close_connection ( void  )
static

Definition at line 5576 of file http.c.

5577{
5578 char c;
5580 recv(server_socket, &c, 1, 0);
5581}
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
static HANDLE conn_wait_event
Definition: http.c:114
static int server_socket
Definition: http.c:2199

Referenced by _send_response_and_wait(), _send_response_ex_and_wait(), finished_reading(), release_object(), send_response_len_and_wait(), test_connection_break(), test_large_content(), test_persistent_connection(), and test_redirect().

◆ closetest_callback()

static void WINAPI closetest_callback ( HINTERNET  hInternet,
DWORD_PTR  dwContext,
DWORD  dwInternetStatus,
LPVOID  lpvStatusInformation,
DWORD  dwStatusInformationLength 
)
static

Definition at line 7705 of file http.c.

7707{
7708 DWORD len, type;
7709 BOOL res;
7710
7711 if(winetest_debug > 1)
7712 trace("closetest_callback %p: %d\n", hInternet, dwInternetStatus);
7713
7714 ok(hInternet == closetest_session || hInternet == closetest_conn || hInternet == closetest_req,
7715 "Unexpected hInternet %p\n", hInternet);
7716 if(!closetest_closed)
7717 return;
7718
7719 len = sizeof(type);
7722 "InternetQueryOptionA(%p INTERNET_OPTION_HANDLE_TYPE) failed: %x %u, expected TRUE ERROR_INVALID_HANDLE\n",
7724}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
static HINTERNET closetest_session
Definition: http.c:7702
static HINTERNET closetest_req
Definition: http.c:7702
static BOOL closetest_closed
Definition: http.c:7703
static HINTERNET closetest_conn
Definition: http.c:7702

Referenced by test_InternetCloseHandle().

◆ free_events()

static void free_events ( void  )
static

Definition at line 229 of file http.c.

230{
236}
#define CloseHandle
Definition: compat.h:739
static HANDLE conn_close_event
Definition: http.c:114
static HANDLE request_sent_event
Definition: http.c:114
static HANDLE server_req_rec_event
Definition: http.c:114

Referenced by START_TEST().

◆ header_cb()

static void WINAPI header_cb ( HINTERNET  handle,
DWORD_PTR  ctx,
DWORD  status,
LPVOID  info,
DWORD  len 
)
static

Definition at line 7906 of file http.c.

7907{
7908 BOOL ret;
7909 DWORD index, size;
7910 char buf[256];
7911
7913 {
7914 ret = HttpAddRequestHeadersA( handle, "winetest: winetest", ~0u, HTTP_ADDREQ_FLAG_ADD );
7915 ok( ret, "HttpAddRequestHeadersA failed %u\n", GetLastError() );
7916 SetEvent( (HANDLE)ctx );
7917 }
7919 {
7920 index = 0;
7921 size = sizeof(buf);
7923 buf, &size, &index );
7924 ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
7925 ok( strstr( buf, "winetest: winetest" ) != NULL, "header missing\n" );
7926 SetEvent( (HANDLE)ctx );
7927 }
7928}
BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest, LPCSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1329
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 HTTP_QUERY_RAW_HEADERS_CRLF
Definition: wininet.h:1545
#define HTTP_ADDREQ_FLAG_ADD
Definition: wininet.h:1707

Referenced by test_concurrent_header_access().

◆ HttpHeaders_test()

static void HttpHeaders_test ( void  )
static

Definition at line 1766 of file http.c.

1767{
1768 HINTERNET hSession;
1769 HINTERNET hConnect;
1770 HINTERNET hRequest;
1771 CHAR buffer[256];
1772 WCHAR wbuffer[256];
1773 DWORD len = 256;
1774 DWORD oldlen;
1775 DWORD index = 0;
1776 BOOL ret;
1777
1778 hSession = InternetOpenA("Wine Regression Test",
1780 ok( hSession != NULL ,"Unable to open Internet session\n");
1781 hConnect = InternetConnectA(hSession, "test.winehq.org",
1783 0);
1784 ok( hConnect != NULL, "Unable to connect to http://test.winehq.org\n");
1785 hRequest = HttpOpenRequestA(hConnect, "POST", "/tests/post.php",
1787 if (!hRequest && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)
1788 {
1789 skip( "Network unreachable, skipping test\n" );
1790 goto done;
1791 }
1792 ok( hRequest != NULL, "Failed to open request handle\n");
1793
1794 index = 0;
1795 len = sizeof(buffer);
1796 strcpy(buffer,"Warning");
1798 buffer,&len,&index)==0,"Warning hearder reported as Existing\n");
1799
1800 ok(HttpAddRequestHeadersA(hRequest,"Warning:test1",-1,HTTP_ADDREQ_FLAG_ADD),
1801 "Failed to add new header\n");
1802
1803 index = 0;
1804 len = sizeof(buffer);
1805 strcpy(buffer,"Warning");
1807 buffer,&len,&index),"Unable to query header\n");
1808 ok(index == 1, "Index was not incremented\n");
1809 ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
1810 ok(len == 5, "Invalid length (exp. 5, got %d)\n", len);
1811 ok((len < sizeof(buffer)) && (buffer[len] == 0), "Buffer not NULL-terminated\n"); /* len show only 5 characters but the buffer is NULL-terminated*/
1812 len = sizeof(buffer);
1813 strcpy(buffer,"Warning");
1815 buffer,&len,&index)==0,"Second Index Should Not Exist\n");
1816
1817 index = 0;
1818 len = 5; /* could store the string but not the NULL terminator */
1819 strcpy(buffer,"Warning");
1821 buffer,&len,&index) == FALSE,"Query succeeded on a too small buffer\n");
1822 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
1823 ok(index == 0, "Index was incremented\n");
1824 ok(strcmp(buffer,"Warning")==0, "incorrect string was returned(%s)\n",buffer); /* string not touched */
1825 ok(len == 6, "Invalid length (exp. 6, got %d)\n", len); /* unlike success, the length includes the NULL-terminator */
1826
1827 /* a call with NULL will fail but will return the length */
1828 index = 0;
1829 len = sizeof(buffer);
1830 SetLastError(0xdeadbeef);
1832 NULL,&len,&index) == FALSE,"Query worked\n");
1833 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
1834 ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
1835 ok(index == 0, "Index was incremented\n");
1836
1837 /* even for a len that is too small */
1838 index = 0;
1839 len = 15;
1840 SetLastError(0xdeadbeef);
1842 NULL,&len,&index) == FALSE,"Query worked\n");
1843 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
1844 ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
1845 ok(index == 0, "Index was incremented\n");
1846
1847 index = 0;
1848 len = 0;
1849 SetLastError(0xdeadbeef);
1851 NULL,&len,&index) == FALSE,"Query worked\n");
1852 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
1853 ok(len > 40, "Invalid length (exp. more than 40, got %d)\n", len);
1854 ok(index == 0, "Index was incremented\n");
1855 oldlen = len; /* bytes; at least long enough to hold buffer & nul */
1856
1857
1858 /* a working query */
1859 index = 0;
1860 len = sizeof(buffer);
1861 memset(buffer, 'x', sizeof(buffer));
1863 buffer,&len,&index),"Unable to query header\n");
1864 ok(len + sizeof(CHAR) <= oldlen, "Result longer than advertised\n");
1865 ok((len < sizeof(buffer)-sizeof(CHAR)) && (buffer[len/sizeof(CHAR)] == 0),"No NUL at end\n");
1866 ok(len == strlen(buffer) * sizeof(CHAR), "Length wrong\n");
1867 /* what's in the middle differs between Wine and Windows so currently we check only the beginning and the end */
1868 ok(strncmp(buffer, "POST /tests/post.php HTTP/1", 25)==0, "Invalid beginning of headers string\n");
1869 ok(strcmp(buffer + strlen(buffer) - 4, "\r\n\r\n")==0, "Invalid end of headers string\n");
1870 ok(index == 0, "Index was incremented\n");
1871
1872 /* Like above two tests, but for W version */
1873
1874 index = 0;
1875 len = 0;
1876 SetLastError(0xdeadbeef);
1878 NULL,&len,&index) == FALSE,"Query worked\n");
1879 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
1880 ok(len > 80, "Invalid length (exp. more than 80, got %d)\n", len);
1881 ok(index == 0, "Index was incremented\n");
1882 oldlen = len; /* bytes; at least long enough to hold buffer & nul */
1883
1884 /* a working query */
1885 index = 0;
1886 len = sizeof(wbuffer);
1887 memset(wbuffer, 'x', sizeof(wbuffer));
1889 wbuffer,&len,&index),"Unable to query header\n");
1890 ok(len + sizeof(WCHAR) <= oldlen, "Result longer than advertised\n");
1891 ok(len == lstrlenW(wbuffer) * sizeof(WCHAR), "Length wrong\n");
1892 ok((len < sizeof(wbuffer)-sizeof(WCHAR)) && (wbuffer[len/sizeof(WCHAR)] == 0),"No NUL at end\n");
1893 ok(index == 0, "Index was incremented\n");
1894
1895 /* end of W version tests */
1896
1897 /* Without HTTP_QUERY_FLAG_REQUEST_HEADERS */
1898 index = 0;
1899 len = sizeof(buffer);
1900 memset(buffer, 'x', sizeof(buffer));
1902 buffer,&len,&index) == TRUE,"Query failed\n");
1903 ok(len == 2 || len == 4 /* win10 */, "Expected 2 or 4, got %d\n", len);
1904 ok(memcmp(buffer, "\r\n\r\n", len) == 0, "Expected CRLF, got '%s'\n", buffer);
1905 ok(index == 0, "Index was incremented\n");
1906
1907 ok(HttpAddRequestHeadersA(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
1908 "Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
1909
1910 index = 0;
1911 len = sizeof(buffer);
1912 strcpy(buffer,"Warning");
1914 buffer,&len,&index),"Unable to query header\n");
1915 ok(index == 1, "Index was not incremented\n");
1916 ok(strcmp(buffer,"test1")==0, "incorrect string was returned(%s)\n",buffer);
1917 len = sizeof(buffer);
1918 strcpy(buffer,"Warning");
1920 buffer,&len,&index),"Failed to get second header\n");
1921 ok(index == 2, "Index was not incremented\n");
1922 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
1923 len = sizeof(buffer);
1924 strcpy(buffer,"Warning");
1926 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1927
1928 ok(HttpAddRequestHeadersA(hRequest,"Warning:test3",-1,HTTP_ADDREQ_FLAG_REPLACE), "Failed to replace header using HTTP_ADDREQ_FLAG_REPLACE\n");
1929
1930 index = 0;
1931 len = sizeof(buffer);
1932 strcpy(buffer,"Warning");
1934 buffer,&len,&index),"Unable to query header\n");
1935 ok(index == 1, "Index was not incremented\n");
1936 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
1937 len = sizeof(buffer);
1938 strcpy(buffer,"Warning");
1940 buffer,&len,&index),"Failed to get second header\n");
1941 ok(index == 2, "Index was not incremented\n");
1942 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1943 len = sizeof(buffer);
1944 strcpy(buffer,"Warning");
1946 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1947
1948 ok(HttpAddRequestHeadersA(hRequest,"Warning:test4",-1,HTTP_ADDREQ_FLAG_ADD_IF_NEW)==0, "HTTP_ADDREQ_FLAG_ADD_IF_NEW replaced existing header\n");
1949
1950 index = 0;
1951 len = sizeof(buffer);
1952 strcpy(buffer,"Warning");
1954 buffer,&len,&index),"Unable to query header\n");
1955 ok(index == 1, "Index was not incremented\n");
1956 ok(strcmp(buffer,"test2")==0, "incorrect string was returned(%s)\n",buffer);
1957 len = sizeof(buffer);
1958 strcpy(buffer,"Warning");
1960 buffer,&len,&index),"Failed to get second header\n");
1961 ok(index == 2, "Index was not incremented\n");
1962 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1963 len = sizeof(buffer);
1964 strcpy(buffer,"Warning");
1966 buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1967
1968 ok(HttpAddRequestHeadersA(hRequest,"Warning:test4",-1, HTTP_ADDREQ_FLAG_COALESCE), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
1969
1970 index = 0;
1971 len = sizeof(buffer);
1972 strcpy(buffer,"Warning");
1974 buffer,&len,&index),"Unable to query header\n");
1975 ok(index == 1, "Index was not incremented\n");
1976 ok(strcmp(buffer,"test2, test4")==0, "incorrect string was returned(%s)\n", buffer);
1977 len = sizeof(buffer);
1978 strcpy(buffer,"Warning");
1979 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
1980 ok(index == 2, "Index was not incremented\n");
1981 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1982 len = sizeof(buffer);
1983 strcpy(buffer,"Warning");
1984 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
1985
1986 ok(HttpAddRequestHeadersA(hRequest,"Warning:test5",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
1987
1988 index = 0;
1989 len = sizeof(buffer);
1990 strcpy(buffer,"Warning");
1991 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
1992 ok(index == 1, "Index was not incremented\n");
1993 ok(strcmp(buffer,"test2, test4, test5")==0, "incorrect string was returned(%s)\n",buffer);
1994 len = sizeof(buffer);
1995 strcpy(buffer,"Warning");
1996 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
1997 ok(index == 2, "Index was not incremented\n");
1998 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
1999 len = sizeof(buffer);
2000 strcpy(buffer,"Warning");
2001 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2002
2003 ok(HttpAddRequestHeadersA(hRequest,"Warning:test6",-1, HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON), "HTTP_ADDREQ_FLAG_COALESCE Did not work\n");
2004
2005 index = 0;
2006 len = sizeof(buffer);
2007 strcpy(buffer,"Warning");
2008 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2009 ok(index == 1, "Index was not incremented\n");
2010 ok(strcmp(buffer,"test2, test4, test5; test6")==0, "incorrect string was returned(%s)\n",buffer);
2011 len = sizeof(buffer);
2012 strcpy(buffer,"Warning");
2013 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
2014 ok(index == 2, "Index was not incremented\n");
2015 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
2016 len = sizeof(buffer);
2017 strcpy(buffer,"Warning");
2018 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2019
2020 ok(HttpAddRequestHeadersA(hRequest,"Warning:test7",-1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE), "HTTP_ADDREQ_FLAG_ADD with HTTP_ADDREQ_FLAG_REPALCE Did not work\n");
2021
2022 index = 0;
2023 len = sizeof(buffer);
2024 strcpy(buffer,"Warning");
2025 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2026 ok(index == 1, "Index was not incremented\n");
2027 ok(strcmp(buffer,"test3")==0, "incorrect string was returned(%s)\n",buffer);
2028 len = sizeof(buffer);
2029 strcpy(buffer,"Warning");
2030 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Failed to get second header\n");
2031 ok(index == 2, "Index was not incremented\n");
2032 ok(strcmp(buffer,"test7")==0, "incorrect string was returned(%s)\n",buffer);
2033 len = sizeof(buffer);
2034 strcpy(buffer,"Warning");
2035 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index)==0,"Third Header Should Not Exist\n");
2036
2037 /* Ensure that blank headers are ignored and don't cause a failure */
2038 ok(HttpAddRequestHeadersA(hRequest,"\r\nBlankTest:value\r\n\r\n",-1, HTTP_ADDREQ_FLAG_ADD_IF_NEW), "Failed to add header with blank entries in list\n");
2039
2040 index = 0;
2041 len = sizeof(buffer);
2042 strcpy(buffer,"BlankTest");
2043 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2044 ok(index == 1, "Index was not incremented\n");
2045 ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
2046
2047 /* Ensure that malformed header separators are ignored and don't cause a failure */
2048 ok(HttpAddRequestHeadersA(hRequest,"\r\rMalformedTest:value\n\nMalformedTestTwo: value2\rMalformedTestThree: value3\n\n\r\r\n",-1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE),
2049 "Failed to add header with malformed entries in list\n");
2050
2051 index = 0;
2052 len = sizeof(buffer);
2053 strcpy(buffer,"MalformedTest");
2054 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2055 ok(index == 1, "Index was not incremented\n");
2056 ok(strcmp(buffer,"value")==0, "incorrect string was returned(%s)\n",buffer);
2057 index = 0;
2058 len = sizeof(buffer);
2059 strcpy(buffer,"MalformedTestTwo");
2060 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2061 ok(index == 1, "Index was not incremented\n");
2062 ok(strcmp(buffer,"value2")==0, "incorrect string was returned(%s)\n",buffer);
2063 index = 0;
2064 len = sizeof(buffer);
2065 strcpy(buffer,"MalformedTestThree");
2066 ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index),"Unable to query header\n");
2067 ok(index == 1, "Index was not incremented\n");
2068 ok(strcmp(buffer,"value3")==0, "incorrect string was returned(%s)\n",buffer);
2069
2070 ret = HttpAddRequestHeadersA(hRequest, "Authorization: Basic\r\n", -1, HTTP_ADDREQ_FLAG_ADD);
2071 ok(ret, "unable to add header %u\n", GetLastError());
2072
2073 index = 0;
2074 buffer[0] = 0;
2075 len = sizeof(buffer);
2077 ok(ret, "unable to query header %u\n", GetLastError());
2078 ok(index == 1, "index was not incremented\n");
2079 ok(!strcmp(buffer, "Basic"), "incorrect string was returned (%s)\n", buffer);
2080
2081 ret = HttpAddRequestHeadersA(hRequest, "Authorization:\r\n", -1, HTTP_ADDREQ_FLAG_REPLACE);
2082 ok(ret, "unable to remove header %u\n", GetLastError());
2083
2084 index = 0;
2085 len = sizeof(buffer);
2086 SetLastError(0xdeadbeef);
2088 "header still present\n");
2090
2091 ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
2092done:
2093 ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
2094 ok(InternetCloseHandle(hSession), "Close session handle failed\n");
2095}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define skip(...)
Definition: atltest.h:64
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define lstrlenW
Definition: compat.h:750
#define INTERNET_DEFAULT_HTTP_PORT
Definition: winhttp.h:36
#define HTTP_ADDREQ_FLAG_REPLACE
Definition: wininet.h:1711
#define HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
Definition: wininet.h:1709
#define HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Definition: wininet.h:1708
#define INTERNET_FLAG_NO_CACHE_WRITE
Definition: wininet.h:66
#define HTTP_QUERY_AUTHORIZATION
Definition: wininet.h:1551
#define HTTP_ADDREQ_FLAG_COALESCE
Definition: wininet.h:1710
#define INTERNET_OPEN_TYPE_PRECONFIG
Definition: wininet.h:521
#define HTTP_QUERY_CUSTOM
Definition: wininet.h:1603
#define HTTP_ADDREQ_FLAG_ADD_IF_NEW
Definition: wininet.h:1706
#define ERROR_INTERNET_NAME_NOT_RESOLVED
Definition: wininet.h:1996
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ HttpSendRequestEx_test()

static void HttpSendRequestEx_test ( void  )
static

Definition at line 1353 of file http.c.

1354{
1355 HINTERNET hSession;
1356 HINTERNET hConnect;
1357 HINTERNET hRequest;
1358
1359 INTERNET_BUFFERSA BufferIn;
1360 DWORD dwBytesWritten, dwBytesRead, error;
1361 CHAR szBuffer[256];
1362 int i;
1363 BOOL ret;
1364
1365 static char szPostData[] = "mode=Test";
1366 static const char szContentType[] = "Content-Type: application/x-www-form-urlencoded";
1367
1368 hSession = InternetOpenA("Wine Regression Test",
1370 ok( hSession != NULL ,"Unable to open Internet session\n");
1371 hConnect = InternetConnectA(hSession, "test.winehq.org",
1373 0);
1374 ok( hConnect != NULL, "Unable to connect to http://test.winehq.org\n");
1375 hRequest = HttpOpenRequestA(hConnect, "POST", "/tests/post.php",
1377 if (!hRequest && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)
1378 {
1379 skip( "Network unreachable, skipping test\n" );
1380 goto done;
1381 }
1382 ok( hRequest != NULL, "Failed to open request handle err %u\n", GetLastError());
1383
1385
1386 BufferIn.dwStructSize = sizeof(BufferIn);
1387 BufferIn.Next = (INTERNET_BUFFERSA*)0xdeadcab;
1388 BufferIn.lpcszHeader = szContentType;
1389 BufferIn.dwHeadersLength = sizeof(szContentType)-1;
1390 BufferIn.dwHeadersTotal = sizeof(szContentType)-1;
1391 BufferIn.lpvBuffer = szPostData;
1392 BufferIn.dwBufferLength = 3;
1393 BufferIn.dwBufferTotal = sizeof(szPostData)-1;
1394 BufferIn.dwOffsetLow = 0;
1395 BufferIn.dwOffsetHigh = 0;
1396
1397 SetLastError(0xdeadbeef);
1398 ret = HttpSendRequestExA(hRequest, &BufferIn, NULL, 0 ,0);
1399 error = GetLastError();
1400 ok(ret, "HttpSendRequestEx Failed with error %u\n", error);
1401 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1402
1404
1405 for (i = 3; szPostData[i]; i++)
1406 ok(InternetWriteFile(hRequest, &szPostData[i], 1, &dwBytesWritten),
1407 "InternetWriteFile failed\n");
1408
1410
1411 ok(HttpEndRequestA(hRequest, NULL, 0, 0), "HttpEndRequest Failed\n");
1412
1413 test_request_flags(hRequest, 0);
1414
1415 ok(InternetReadFile(hRequest, szBuffer, 255, &dwBytesRead),
1416 "Unable to read response\n");
1417 szBuffer[dwBytesRead] = 0;
1418
1419 ok(dwBytesRead == 13,"Read %u bytes instead of 13\n",dwBytesRead);
1420 ok(strncmp(szBuffer,"mode => Test\n",dwBytesRead)==0 || broken(proxy_active()),"Got string %s\n",szBuffer);
1421
1422 ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
1423done:
1424 ok(InternetCloseHandle(hConnect), "Close connect handle failed\n");
1425 ok(InternetCloseHandle(hSession), "Close session handle failed\n");
1426}
#define broken(x)
Definition: _sntprintf.h:21
BOOL WINAPI HttpEndRequestA(HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5349
BOOL WINAPI HttpSendRequestExA(HINTERNET hRequest, LPINTERNET_BUFFERSA lpBuffersIn, LPINTERNET_BUFFERSA lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5445
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2114
#define test_request_flags(a, b)
Definition: http.c:321
static BOOL proxy_active(void)
Definition: http.c:201
DWORD dwOffsetHigh
Definition: wininet.h:268
DWORD dwHeadersLength
Definition: wininet.h:262
DWORD dwStructSize
Definition: wininet.h:259
LPCSTR lpcszHeader
Definition: wininet.h:261
DWORD dwBufferLength
Definition: wininet.h:265
DWORD dwBufferTotal
Definition: wininet.h:266
struct _INTERNET_BUFFERSA * Next
Definition: wininet.h:260
LPVOID lpvBuffer
Definition: wininet.h:264
DWORD dwHeadersTotal
Definition: wininet.h:263
#define INTERNET_REQFLAG_NO_HEADERS
Definition: wininet.h:58

Referenced by START_TEST().

◆ init_events()

static void init_events ( void  )
static

Definition at line 220 of file http.c.

221{
227}
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651

Referenced by START_TEST().

◆ init_status_tests()

static void init_status_tests ( void  )
static

Definition at line 7868 of file http.c.

7869{
7870 memset(expect, 0, sizeof(expect));
7871 memset(optional, 0, sizeof(optional));
7872 memset(wine_allow, 0, sizeof(wine_allow));
7873 memset(notified, 0, sizeof(notified));
7874 memset(status_string, 0, sizeof(status_string));
7875
7876#define STATUS_STRING(status) status_string[status] = #status
7903#undef STATUS_STRING
7904}
#define STATUS_STRING(status)
#define INTERNET_STATUS_STATE_CHANGE
Definition: wininet.h:902
#define INTERNET_STATUS_COOKIE_RECEIVED
Definition: wininet.h:904
#define INTERNET_STATUS_USER_INPUT_REQUIRED
Definition: wininet.h:901
#define INTERNET_STATUS_COOKIE_HISTORY
Definition: wininet.h:908
#define INTERNET_STATUS_COOKIE_SENT
Definition: wininet.h:903
#define INTERNET_STATUS_P3P_HEADER
Definition: wininet.h:906
#define INTERNET_STATUS_PRIVACY_IMPACTED
Definition: wininet.h:905
#define INTERNET_STATUS_P3P_POLICYREF
Definition: wininet.h:907

Referenced by START_TEST().

◆ INTERNET_STATUS_CALLBACK()

static INTERNET_STATUS_CALLBACK ( WINAPI pInternetSetStatusCallbackA)
static

◆ InternetLockRequestFile_test()

static void InternetLockRequestFile_test ( void  )
static

Definition at line 1713 of file http.c.

1714{
1715 char file_name[MAX_PATH];
1716 test_request_t req;
1717 HANDLE lock, lock2;
1718 DWORD size;
1719 BOOL ret;
1720
1721 open_simple_request(&req, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, "/tests/hello.html");
1722
1723 size = sizeof(file_name);
1725 ok(!ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) succeeded\n");
1726 ok(GetLastError() == ERROR_INTERNET_ITEM_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
1727 ok(!size, "size = %d\n", size);
1728
1729 lock = NULL;
1731 ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "InternetLockRequestFile returned: %x(%u)\n", ret, GetLastError());
1732
1733 ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
1734 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
1735
1736 size = sizeof(file_name);
1738 ok(ret, "InternetQueryOptionA(INTERNET_OPTION_DATAFILE_NAME) failed: %u\n", GetLastError());
1739
1741 ok(ret, "InternetLockRequestFile returned: %x(%u)\n", ret, GetLastError());
1742 ok(lock != NULL, "lock == NULL\n");
1743
1744 ret = InternetLockRequestFile(req.request, &lock2);
1745 ok(ret, "InternetLockRequestFile returned: %x(%u)\n", ret, GetLastError());
1746 ok(lock == lock2, "lock != lock2\n");
1747
1749 ok(ret, "InternetUnlockRequestFile failed: %u\n", GetLastError());
1750
1752 ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%u)\n", ret, GetLastError());
1753
1754 ok(InternetCloseHandle(req.request), "Close request handle failed\n");
1755
1757 ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION, "Deleting file returned %x(%u)\n", ret, GetLastError());
1758
1760 ok(ret, "InternetUnlockRequestFile failed: %u\n", GetLastError());
1761
1763 ok(ret, "Deleting file returned %x(%u)\n", ret, GetLastError());
1764}
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5677
BOOL WINAPI InternetLockRequestFile(HINTERNET hInternet, HANDLE *lphLockReqHandle)
Definition: internet.c:4032
BOOL WINAPI InternetUnlockRequestFile(HANDLE hLockHandle)
Definition: internet.c:4061
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static LPCWSTR file_name
Definition: protocol.c:147
#define open_simple_request(a, b, c, d, e)
Definition: http.c:533
rwlock_t lock
Definition: tcpcore.h:0
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:135
#define ERROR_INTERNET_ITEM_NOT_FOUND
Definition: wininet.h:2017
#define INTERNET_OPTION_DATAFILE_NAME
Definition: wininet.h:727

Referenced by START_TEST().

◆ InternetOpenRequest_test()

static void InternetOpenRequest_test ( void  )
static

Definition at line 1428 of file http.c.

1429{
1431 static const char *types[] = { "*", "", NULL };
1432 static const WCHAR slash[] = {'/', 0}, any[] = {'*', 0}, empty[] = {0};
1433 static const WCHAR *typesW[] = { any, empty, NULL };
1434 BOOL ret;
1435
1436 session = InternetOpenA("Wine Regression Test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
1437 ok(session != NULL ,"Unable to open Internet session\n");
1438
1440 INTERNET_SERVICE_HTTP, 0, 0);
1441 ok(connect == NULL, "InternetConnectA should have failed\n");
1442 ok(GetLastError() == ERROR_INVALID_PARAMETER, "InternetConnectA with NULL server named should have failed with ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
1443
1445 INTERNET_SERVICE_HTTP, 0, 0);
1446 ok(connect == NULL, "InternetConnectA should have failed\n");
1447 ok(GetLastError() == ERROR_INVALID_PARAMETER, "InternetConnectA with blank server named should have failed with ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
1448
1450 INTERNET_SERVICE_HTTP, 0, 0);
1451 ok(connect != NULL, "Unable to connect to http://test.winehq.org with error %d\n", GetLastError());
1452
1455 {
1456 skip( "Network unreachable, skipping test\n" );
1457 goto done;
1458 }
1459 ok(request != NULL, "Failed to open request handle err %u\n", GetLastError());
1460
1462 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
1463 ok(InternetCloseHandle(request), "Close request handle failed\n");
1464
1466 ok(request != NULL, "Failed to open request handle err %u\n", GetLastError());
1467
1469 ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
1470 ok(InternetCloseHandle(request), "Close request handle failed\n");
1471
1472done:
1473 ok(InternetCloseHandle(connect), "Close connect handle failed\n");
1474 ok(InternetCloseHandle(session), "Close session handle failed\n");
1475}
static const WCHAR empty[]
Definition: main.c:47
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5595
HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession, LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion, LPCWSTR lpszReferrer, LPCWSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:3469
Definition: tftpd.h:86
Definition: cmds.c:130

Referenced by START_TEST().

◆ InternetOpenUrlA_test()

static void InternetOpenUrlA_test ( void  )
static

Definition at line 1316 of file http.c.

1317{
1318 HINTERNET myhinternet, myhttp;
1319 char buffer[0x400];
1320 DWORD size, readbytes, totalbytes=0;
1321 BOOL ret;
1322
1325 "DeleteUrlCacheEntry returned %x, GetLastError() = %d\n", ret, GetLastError());
1326
1327 myhinternet = InternetOpenA("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
1328 ok((myhinternet != 0), "InternetOpen failed, error %u\n",GetLastError());
1329 size = 0x400;
1331 ok( ret, "InternetCanonicalizeUrl failed, error %u\n",GetLastError());
1332
1333 SetLastError(0);
1334 myhttp = InternetOpenUrlA(myhinternet, TEST_URL, 0, 0,
1337 return; /* WinXP returns this when not connected to the net */
1338 ok((myhttp != 0),"InternetOpenUrl failed, error %u\n",GetLastError());
1339 ret = InternetReadFile(myhttp, buffer,0x400,&readbytes);
1340 ok( ret, "InternetReadFile failed, error %u\n",GetLastError());
1341 totalbytes += readbytes;
1342 while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
1343 totalbytes += readbytes;
1344 trace("read 0x%08x bytes\n",totalbytes);
1345
1346 InternetCloseHandle(myhttp);
1347 InternetCloseHandle(myhinternet);
1348
1350 ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "INTERNET_FLAG_NO_CACHE_WRITE flag doesn't work\n");
1351}
BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:1978
HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl, LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3779
BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName)
Definition: urlcache.c:3298
#define TEST_URL
Definition: http.c:42
#define ICU_BROWSER_MODE
Definition: winhttp.h:294
#define INTERNET_FLAG_RELOAD
Definition: wininet.h:61
#define INTERNET_FLAG_TRANSFER_BINARY
Definition: wininet.h:91

Referenced by START_TEST().

◆ InternetReadFile_chunked_test()

static void InternetReadFile_chunked_test ( void  )
static

Definition at line 962 of file http.c.

963{
964 BOOL res;
965 CHAR buffer[4000];
966 DWORD length, got;
967 const char *types[2] = { "*", NULL };
968 HINTERNET hi, hic = 0, hor = 0;
969
970 trace("Starting InternetReadFile chunked test\n");
971
972 trace("InternetOpenA <--\n");
974 ok((hi != 0x0),"InternetOpen failed with error %u\n", GetLastError());
975 trace("InternetOpenA -->\n");
976
977 if (hi == 0x0) goto abort;
978
979 trace("InternetConnectA <--\n");
980 hic=InternetConnectA(hi, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER,
981 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
982 ok((hic != 0x0),"InternetConnect failed with error %u\n", GetLastError());
983 trace("InternetConnectA -->\n");
984
985 if (hic == 0x0) goto abort;
986
987 trace("HttpOpenRequestA <--\n");
988 hor = HttpOpenRequestA(hic, "GET", "/tests/chunked", NULL, NULL, types,
990 0xdeadbead);
991 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
992 /*
993 * If the internet name can't be resolved we are probably behind
994 * a firewall or in some other way not directly connected to the
995 * Internet. Not enough reason to fail the test. Just ignore and
996 * abort.
997 */
998 } else {
999 ok((hor != 0x0),"HttpOpenRequest failed with error %u\n", GetLastError());
1000 }
1001 trace("HttpOpenRequestA -->\n");
1002
1003 if (hor == 0x0) goto abort;
1004
1005 trace("HttpSendRequestA -->\n");
1006 SetLastError(0xdeadbeef);
1007 res = HttpSendRequestA(hor, "", -1, NULL, 0);
1009 "Synchronous HttpSendRequest returning 0, error %u\n", GetLastError());
1010 trace("HttpSendRequestA <--\n");
1011
1012 test_request_flags(hor, 0);
1013
1014 length = 100;
1016 buffer[length]=0;
1017 trace("Option CONTENT_TYPE -> %i %s\n",res,buffer);
1018
1019 SetLastError( 0xdeadbeef );
1020 length = 100;
1022 buffer[length]=0;
1023 trace("Option TRANSFER_ENCODING -> %i %s\n",res,buffer);
1025 "Failed to get TRANSFER_ENCODING option, error %u\n", GetLastError() );
1026 ok( !strcmp( buffer, "chunked" ) || ( ! res && proxy_active() && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND ),
1027 "Wrong transfer encoding '%s'\n", buffer );
1028
1029 SetLastError( 0xdeadbeef );
1030 length = 16;
1032 ok( !res, "Found CONTENT_LENGTH option '%s'\n", buffer );
1033 ok( GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "Wrong error %u\n", GetLastError() );
1034
1035 length = 100;
1036 trace("Entering Query loop\n");
1037
1038 while (TRUE)
1039 {
1040 res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
1041 ok(!(!res && length != 0),"InternetQueryDataAvailable failed with non-zero length\n");
1042 ok(res, "InternetQueryDataAvailable failed, error %d\n", GetLastError());
1043 trace("got %u available\n",length);
1044 if (length)
1045 {
1046 char *buffer = HeapAlloc(GetProcessHeap(),0,length+1);
1047
1048 SetLastError(0xdeadbeef);
1049 res = InternetReadFile(hor,buffer,length,&got);
1050 ok(GetLastError() == 0 ||
1051 broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %u\n", GetLastError());
1052
1053 buffer[got]=0;
1054 trace("ReadFile -> %i %i\n",res,got);
1055 ok( length == got, "only got %u of %u available\n", got, length );
1056 ok( buffer[got-1] == '\n', "received partial line '%s'\n", buffer );
1057
1059 if (!got) break;
1060 }
1061 if (length == 0)
1062 {
1063 got = 0xdeadbeef;
1064 SetLastError(0xdeadbeef);
1065 res = InternetReadFile( hor, buffer, 1, &got );
1066 ok( res, "InternetReadFile failed: %u\n", GetLastError() );
1067 ok(GetLastError() == 0 ||
1068 broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %u\n", GetLastError());
1069 ok( !got, "got %u\n", got );
1070 break;
1071 }
1072 }
1073abort:
1074 trace("aborting\n");
1075 if (hor != 0x0) {
1076 res = InternetCloseHandle(hor);
1077 ok (res, "InternetCloseHandle of handle opened by HttpOpenRequestA failed\n");
1078 }
1079 if (hi != 0x0) {
1081 ok (res, "InternetCloseHandle of handle opened by InternetOpenA failed\n");
1082 }
1083}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define abort()
Definition: i386-dis.c:34
#define INTERNET_FLAG_KEEP_CONNECTION
Definition: wininet.h:72
#define HTTP_QUERY_CONTENT_TYPE
Definition: wininet.h:1524
#define HTTP_QUERY_TRANSFER_ENCODING
Definition: wininet.h:1586
#define INTERNET_INVALID_PORT_NUMBER
Definition: wininet.h:36
#define HTTP_QUERY_CONTENT_LENGTH
Definition: wininet.h:1528

Referenced by START_TEST().

◆ InternetReadFile_test()

static void InternetReadFile_test ( int  flags,
const test_data_t test 
)
static

Definition at line 585 of file http.c.

586{
587 char *post_data = NULL;
588 BOOL res, on_async = TRUE;
589 CHAR buffer[4000];
590 WCHAR wbuffer[4000];
591 DWORD length, length2, index, exlen = 0, post_len = 0;
592 const char *types[2] = { "*", NULL };
593 HINTERNET hi, hic = 0, hor = 0;
594 DWORD contents_length, accepts_ranges;
595 BOOL not_supported;
596
597 trace("Starting InternetReadFile test with flags 0x%x on url %s\n",flags,test->url);
598 reset_events();
599
600 trace("InternetOpenA <--\n");
601 hi = InternetOpenA((test->flags & TESTF_COMPRESSED) ? "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" : "",
603 ok((hi != 0x0),"InternetOpen failed with error %u\n", GetLastError());
604 trace("InternetOpenA -->\n");
605
606 if (hi == 0x0) goto abort;
607
608 pInternetSetStatusCallbackA(hi,&callback);
609
611
612 trace("InternetConnectA <--\n");
614 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
615 ok((hic != 0x0),"InternetConnect failed with error %u\n", GetLastError());
616 trace("InternetConnectA -->\n");
617
618 if (hic == 0x0) goto abort;
619
622
623 trace("HttpOpenRequestA <--\n");
624 hor = HttpOpenRequestA(hic, test->post_data ? "POST" : "GET", test->path, NULL, NULL, types,
626 0xdeadbead);
627 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
628 /*
629 * If the internet name can't be resolved we are probably behind
630 * a firewall or in some other way not directly connected to the
631 * Internet. Not enough reason to fail the test. Just ignore and
632 * abort.
633 */
634 } else {
635 ok((hor != 0x0),"HttpOpenRequest failed with error %u\n", GetLastError());
636 }
637 trace("HttpOpenRequestA -->\n");
638
639 if (hor == 0x0) goto abort;
640
642 test_request_url(hor, test->url);
643
644 length = sizeof(buffer);
646 ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
647 ok(length == 0 || (length == 1 && !*buffer) /* win10 */, "HTTP_QUERY_RAW_HEADERS: expected length 0, but got %d\n", length);
648 ok(!strcmp(buffer, ""), "HTTP_QUERY_RAW_HEADERS: expected string \"\", but got \"%s\"\n", buffer);
649
656 {
659 }
666 if(test->flags & TESTF_REDIRECT) {
669 }
675
676 if(test->flags & TESTF_COMPRESSED) {
677 BOOL b = TRUE;
678
681 "InternetSetOption failed: %u\n", GetLastError());
682 if(!res)
683 goto abort;
684 }
685
686 test_status_code(hor, 0);
687
688 trace("HttpSendRequestA -->\n");
689 if(test->post_data) {
690 post_len = strlen(test->post_data);
691 post_data = HeapAlloc(GetProcessHeap(), 0, post_len);
692 memcpy(post_data, test->post_data, post_len);
693 }
694 SetLastError(0xdeadbeef);
695 res = HttpSendRequestA(hor, test->headers, -1, post_data, post_len);
698 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
699 else
701 "Synchronous HttpSendRequest returning 0, error %u\n", GetLastError());
702 trace("HttpSendRequestA <--\n");
703
706 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
707 }
709
713 {
714 if (! proxy_active())
715 {
718 }
719 else
720 {
723 }
724 }
725 else
726 {
729 }
734 if(test->flags & TESTF_REDIRECT)
738 /* Sent on WinXP only if first_connection_to_test_url is TRUE, on Win98 always sent */
741
742 test_request_flags(hor, 0);
743
744 length = 100;
746 ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed with error %d\n", GetLastError());
747
748 length = sizeof(buffer)-2;
749 memset(buffer, 0x77, sizeof(buffer));
750 SetLastError(0xdeadbeef);
752 ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
753 ok(GetLastError() == 0 ||
754 broken(GetLastError() == 0xdeadbeef /* XP/W2K3 */), "Last Error not reset %u\n", GetLastError());
755 /* show that the function writes data past the length returned */
756 ok(buffer[length-2], "Expected any header character, got 0x00\n");
757 ok(!buffer[length-1], "Expected 0x00, got %02X\n", buffer[length-1]);
758 ok(!buffer[length], "Expected 0x00, got %02X\n", buffer[length]);
759 ok(buffer[length+1] == 0x77, "Expected 0x77, got %02X\n", buffer[length+1]);
760
761 length2 = length;
763 ok(!res, "Expected 0x00, got %d\n", res);
764 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
765 ok(length2 == length+1, "Expected %d, got %d\n", length+1, length2);
766 /* the in length of the buffer must be +1 but the length returned does not count this */
767 length2 = length+1;
768 memset(buffer, 0x77, sizeof(buffer));
770 ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
771 ok(buffer[length2] == 0x00, "Expected 0x00, got %02X\n", buffer[length2]);
772 ok(buffer[length2+1] == 0x77, "Expected 0x77, got %02X\n", buffer[length2+1]);
773 ok(length2 == length, "Value should not have changed: %d != %d\n", length2, length);
774
775 length = sizeof(wbuffer)-2*sizeof(WCHAR);
776 memset(wbuffer, 0x77, sizeof(wbuffer));
777 res = HttpQueryInfoW(hor, HTTP_QUERY_RAW_HEADERS, wbuffer, &length, 0x0);
778 ok(res, "HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
779 ok(length % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length);
780 length /= sizeof(WCHAR);
781 /* show that the function writes data past the length returned */
782 ok(wbuffer[length-2], "Expected any header character, got 0x0000\n");
783 ok(!wbuffer[length-1], "Expected 0x0000, got %04X\n", wbuffer[length-1]);
784 ok(!wbuffer[length], "Expected 0x0000, got %04X\n", wbuffer[length]);
785 ok(wbuffer[length+1] == 0x7777 || broken(wbuffer[length+1] != 0x7777),
786 "Expected 0x7777, got %04X\n", wbuffer[length+1]);
787
788 length2 = length*sizeof(WCHAR);
789 res = HttpQueryInfoW(hor,HTTP_QUERY_RAW_HEADERS,wbuffer,&length2,0x0);
790 ok(!res, "Expected 0x00, got %d\n", res);
791 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
792 ok(length2 % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length2);
793 length2 /= sizeof(WCHAR);
794 ok(length2 == length+1, "Expected %d, got %d\n", length+1, length2);
795 /* the in length of the buffer must be +1 but the length returned does not count this */
796 length2 = (length+1)*sizeof(WCHAR);
797 memset(wbuffer, 0x77, sizeof(wbuffer));
798 res = HttpQueryInfoW(hor,HTTP_QUERY_RAW_HEADERS,wbuffer,&length2,0x0);
799 ok(res, "HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError());
800 ok(length2 % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length2);
801 length2 /= sizeof(WCHAR);
802 ok(!wbuffer[length2], "Expected 0x0000, got %04X\n", wbuffer[length2]);
803 ok(wbuffer[length2+1] == 0x7777, "Expected 0x7777, got %04X\n", wbuffer[length2+1]);
804 ok(length2 == length, "Value should not have changed: %d != %d\n", length2, length);
805
806 test_request_url(hor, test->redirected_url);
807
808 index = 0;
809 length = 0;
810 SetLastError(0xdeadbeef);
812 if(test->flags & TESTF_COMPRESSED)
814 "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", GetLastError());
815 ok(index == 0, "Index was incremented\n");
816
817 index = 0;
818 length = 16;
820 trace("Option HTTP_QUERY_CONTENT_LENGTH -> %i %s (%u)\n",res,buffer,GetLastError());
821 if(test->flags & TESTF_COMPRESSED)
822 {
824 "expected ERROR_HTTP_HEADER_NOT_FOUND, got %x (%u)\n", res, GetLastError());
825 contents_length = 0;
826 }
827 else
828 {
829 contents_length = atoi(buffer);
830 }
831 ok(!res || index == 1, "Index was not incremented although result is %x (index = %u)\n", res, index);
832
833 length = 64;
834 *buffer = 0;
836 trace("Option HTTP_QUERY_ACCEPT_RANGES -> %i %s (%u)\n",res,buffer,GetLastError());
837 accepts_ranges = res && !strcmp(buffer, "bytes");
838
839 length = 100;
841 buffer[length]=0;
842 trace("Option HTTP_QUERY_CONTENT_TYPE -> %i %s\n",res,buffer);
843
844 length = 100;
846 buffer[length]=0;
847 trace("Option HTTP_QUERY_CONTENT_ENCODING -> %i %s\n",res,buffer);
848
849 SetLastError(0xdeadbeef);
851 not_supported = length == INVALID_SET_FILE_POINTER
853 if (accepts_ranges)
854 todo_wine ok((length == contents_length && (GetLastError() == ERROR_SUCCESS
855 || broken(GetLastError() == 0xdeadbeef))) || broken(not_supported),
856 "Got unexpected length %#x, GetLastError() %u, contents_length %u, accepts_ranges %#x.\n",
857 length, GetLastError(), contents_length, accepts_ranges);
858 else
859 ok(not_supported, "Got unexpected length %#x, GetLastError() %u.\n", length, GetLastError());
860
862 {
863 SetLastError(0xdeadbeef);
865 ok(!length && (GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef)),
866 "Got unexpected length %#x, GetLastError() %u.\n", length, GetLastError());
867 }
868
869 SetLastError(0xdeadbeef);
871 ok(!res, "InternetReadFile should have failed\n");
873 "InternetReadFile should have set last error to ERROR_INVALID_HANDLE instead of %u\n",
874 GetLastError());
875
876 length = 100;
877 if(winetest_debug > 1)
878 trace("Entering Query loop\n");
879
880 while (TRUE)
881 {
884
885 /* IE11 calls those in InternetQueryDataAvailable call. */
888
889 length = 0;
890 res = InternetQueryDataAvailable(hor,&length,0x0,0x0);
891
893
895 {
896 if (res)
897 {
899 if(exlen) {
900 ok(length >= exlen, "length %u < exlen %u\n", length, exlen);
901 exlen = 0;
902 }
903 }
904 else if (GetLastError() == ERROR_IO_PENDING)
905 {
906 if(winetest_debug > 1)
907 trace("pending\n");
908 /* on some tests, InternetQueryDataAvailable returns non-zero length and ERROR_IO_PENDING */
909 if(!(test->flags & TESTF_CHUNKED))
910 ok(!length, "InternetQueryDataAvailable returned ERROR_IO_PENDING and %u length\n", length);
912 exlen = length;
913 ok(exlen, "length = 0\n");
916 ok(req_error, "req_error = 0\n");
917 continue;
918 }else {
919 ok(0, "InternetQueryDataAvailable failed: %u\n", GetLastError());
920 }
921 }else {
922 ok(res, "InternetQueryDataAvailable failed: %u\n", GetLastError());
923 }
925
926 if(winetest_debug > 1)
927 trace("length %u\n", length);
928 if(test->flags & TESTF_CHUNKED)
929 ok(length <= 8192, "length = %d, expected <= 8192\n", length);
930 if (length)
931 {
932 char *buffer;
934
936
937 buffer[length]=0;
938
939 if(winetest_debug > 1)
940 trace("ReadFile -> %s %i\n", res ? "TRUE" : "FALSE", length);
941
942 if(test->content)
943 ok(!strcmp(buffer, test->content), "buffer = '%s', expected '%s'\n", buffer, test->content);
945 }else {
946 ok(!on_async, "Returned zero size in response to request complete\n");
947 break;
948 }
949 on_async = FALSE;
950 }
951 if(test->flags & TESTF_REDIRECT) {
954 }
955abort:
956 if(winetest_debug > 1)
957 trace("aborting\n");
958 close_async_handle(hi, 2);
960}
#define FILE_BEGIN
Definition: compat.h:761
#define INVALID_SET_FILE_POINTER
Definition: compat.h:732
DWORD WINAPI InternetSetFilePointer(HINTERNET hFile, LONG lDistanceToMove, PVOID pReserved, DWORD dwMoveContext, DWORD_PTR dwContext)
Definition: internet.c:2095
BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:3131
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static IPrintDialogCallback callback
Definition: printdlg.c:326
static const CHAR post_data[]
Definition: protocol.c:217
#define TESTF_COMPRESSED
Definition: http.c:119
#define SET_OPTIONAL(status)
Definition: http.c:58
static BOOL first_connection_to_test_url
Definition: http.c:44
#define test_request_url(a, b)
Definition: http.c:339
#define CHECK_NOT_NOTIFIED(status)
Definition: http.c:106
static void reset_events(void)
Definition: http.c:238
#define TESTF_REDIRECT
Definition: http.c:118
static void close_async_handle(HINTERNET handle, int handle_cnt)
Definition: http.c:572
#define TESTF_CHUNKED
Definition: http.c:120
#define test_status_code(a, b)
Definition: http.c:247
#define SET_OPTIONAL2(status, num)
Definition: http.c:55
#define test
Definition: rosglue.h:37
#define FILE_END
Definition: winbase.h:114
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
#define HTTP_QUERY_ACCEPT_RANGES
Definition: wininet.h:1565
#define ERROR_INTERNET_INVALID_OPERATION
Definition: wininet.h:2005
#define HTTP_QUERY_RAW_HEADERS
Definition: wininet.h:1544
#define HTTP_QUERY_CONTENT_ENCODING
Definition: wininet.h:1552
#define ERROR_INTERNET_INVALID_OPTION
Definition: wininet.h:1998
#define INTERNET_OPTION_HTTP_DECODING
Definition: wininet.h:758

Referenced by START_TEST().

◆ InternetReadFileExA_test()

static void InternetReadFileExA_test ( int  flags)
static

Definition at line 1085 of file http.c.

1086{
1087 DWORD rc;
1088 DWORD length;
1089 const char *types[2] = { "*", NULL };
1090 HINTERNET hi, hic = 0, hor = 0;
1091 INTERNET_BUFFERSA inetbuffers;
1092
1093 trace("Starting InternetReadFileExA test with flags 0x%x\n",flags);
1094 reset_events();
1095
1096 trace("InternetOpenA <--\n");
1098 ok((hi != 0x0),"InternetOpen failed with error %u\n", GetLastError());
1099 trace("InternetOpenA -->\n");
1100
1101 if (hi == 0x0) goto abort;
1102
1103 pInternetSetStatusCallbackA(hi,&callback);
1104
1106
1107 trace("InternetConnectA <--\n");
1108 hic=InternetConnectA(hi, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER,
1109 NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
1110 ok((hic != 0x0),"InternetConnect failed with error %u\n", GetLastError());
1111 trace("InternetConnectA -->\n");
1112
1113 if (hic == 0x0) goto abort;
1114
1117
1118 trace("HttpOpenRequestA <--\n");
1119 hor = HttpOpenRequestA(hic, "GET", "/tests/redirect", NULL, NULL, types,
1121 0xdeadbead);
1122 if (hor == 0x0 && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) {
1123 /*
1124 * If the internet name can't be resolved we are probably behind
1125 * a firewall or in some other way not directly connected to the
1126 * Internet. Not enough reason to fail the test. Just ignore and
1127 * abort.
1128 */
1129 } else {
1130 ok((hor != 0x0),"HttpOpenRequest failed with error %u\n", GetLastError());
1131 }
1132 trace("HttpOpenRequestA -->\n");
1133
1134 if (hor == 0x0) goto abort;
1135
1140 {
1143 }
1158 else
1160
1161 trace("HttpSendRequestA -->\n");
1162 SetLastError(0xdeadbeef);
1163 rc = HttpSendRequestA(hor, "", -1, NULL, 0);
1165 ok(((rc == 0)&&(GetLastError() == ERROR_IO_PENDING)),
1166 "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
1167 else
1169 "Synchronous HttpSendRequest returning 0, error %u\n", GetLastError());
1170 trace("HttpSendRequestA <--\n");
1171
1172 if (!rc && (GetLastError() == ERROR_IO_PENDING)) {
1174 ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error);
1175