Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
8ead5566
Commit
8ead5566
authored
Jul 30, 2008
by
Zac Brown
Committed by
Alexandre Julliard
Aug 01, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp/tests: Add test for sending request.
parent
dc6fc6ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
winhttp.c
dlls/winhttp/tests/winhttp.c
+73
-0
No files found.
dlls/winhttp/tests/winhttp.c
View file @
8ead5566
...
...
@@ -74,7 +74,80 @@ static void test_OpenRequest (void)
}
static
void
test_SendRequest
(
void
)
{
HINTERNET
session
,
request
,
connection
;
DWORD
header_len
,
optional_len
,
total_len
;
DWORD
bytes_rw
;
BOOL
ret
;
CHAR
buffer
[
256
];
int
i
;
static
const
WCHAR
test_site
[]
=
{
'c'
,
'r'
,
'o'
,
's'
,
's'
,
'o'
,
'v'
,
'e'
,
'r'
,
'.'
,
'c'
,
'o'
,
'd'
,
'e'
,
'w'
,
'e'
,
'a'
,
'v'
,
'e'
,
'r'
,
's'
,
'.'
,
'c'
,
'o'
,
'm'
,
0
};
static
const
WCHAR
content_type
[]
=
{
'C'
,
'o'
,
'n'
,
't'
,
'e'
,
'n'
,
't'
,
'-'
,
'T'
,
'y'
,
'p'
,
'e'
,
':'
,
' '
,
'a'
,
'p'
,
'p'
,
'l'
,
'i'
,
'c'
,
'a'
,
't'
,
'i'
,
'o'
,
'n'
,
'/'
,
'x'
,
'-'
,
'w'
,
'w'
,
'w'
,
'-'
,
'f'
,
'o'
,
'r'
,
'm'
,
'-'
,
'u'
,
'r'
,
'l'
,
'e'
,
'n'
,
'c'
,
'o'
,
'd'
,
'e'
,
'd'
,
0
};
static
const
WCHAR
test_file
[]
=
{
'/'
,
'p'
,
'o'
,
's'
,
't'
,
't'
,
'e'
,
's'
,
't'
,
'.'
,
'p'
,
'h'
,
'p'
,
0
};
static
const
WCHAR
test_verb
[]
=
{
'P'
,
'O'
,
'S'
,
'T'
,
0
};
static
CHAR
post_data
[]
=
"mode=Test"
;
static
CHAR
test_post
[]
=
"mode => Test
\\
0
\n
"
;
header_len
=
-
1L
;
total_len
=
optional_len
=
sizeof
(
post_data
);
memset
(
buffer
,
0xff
,
sizeof
(
buffer
));
session
=
WinHttpOpen
(
test_useragent
,
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
,
WINHTTP_NO_PROXY_NAME
,
WINHTTP_NO_PROXY_BYPASS
,
0
);
todo_wine
ok
(
session
!=
NULL
,
"WinHttpOpen failed to open session.
\n
"
);
connection
=
WinHttpConnect
(
session
,
test_site
,
INTERNET_DEFAULT_HTTP_PORT
,
0
);
todo_wine
ok
(
connection
!=
NULL
,
"WinHttpConnect failed to open a connection, error: %u.
\n
"
,
GetLastError
());
request
=
WinHttpOpenRequest
(
connection
,
test_verb
,
test_file
,
NULL
,
WINHTTP_NO_REFERER
,
WINHTTP_DEFAULT_ACCEPT_TYPES
,
WINHTTP_FLAG_BYPASS_PROXY_CACHE
);
if
(
request
==
NULL
&&
GetLastError
()
==
ERROR_WINHTTP_NAME_NOT_RESOLVED
)
{
skip
(
"Network unreachable, skipping.
\n
"
);
goto
done
;
}
todo_wine
ok
(
request
!=
NULL
,
"WinHttpOpenrequest failed to open a request, error: %u.
\n
"
,
GetLastError
());
ret
=
WinHttpSendRequest
(
request
,
content_type
,
header_len
,
post_data
,
optional_len
,
total_len
,
0
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpSendRequest failed: %u
\n
"
,
GetLastError
());
for
(
i
=
3
;
post_data
[
i
];
i
++
)
{
bytes_rw
=
-
1
;
ret
=
WinHttpWriteData
(
request
,
&
post_data
[
i
],
1
,
&
bytes_rw
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpWriteData failed: %u.
\n
"
,
GetLastError
());
todo_wine
ok
(
bytes_rw
==
1
,
"WinHttpWriteData failed, wrote %u bytes instead of 1 byte.
\n
"
,
bytes_rw
);
}
ret
=
WinHttpReceiveResponse
(
request
,
NULL
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpReceiveResponse failed: %u.
\n
"
,
GetLastError
());
bytes_rw
=
-
1
;
ret
=
WinHttpReadData
(
request
,
buffer
,
sizeof
(
buffer
)
-
1
,
&
bytes_rw
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpReadData failed: %u.
\n
"
,
GetLastError
());
todo_wine
ok
(
bytes_rw
==
strlen
(
test_post
),
"Read %u bytes instead of %d.
\n
"
,
bytes_rw
,
strlen
(
test_post
));
todo_wine
ok
(
strncmp
(
buffer
,
test_post
,
bytes_rw
)
==
0
,
"Data read did not match, got '%s'.
\n
"
,
buffer
);
ret
=
WinHttpCloseHandle
(
request
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpCloseHandle failed on closing request, got %d.
\n
"
,
ret
);
done:
ret
=
WinHttpCloseHandle
(
connection
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpCloseHandle failed on closing connection, got %d.
\n
"
,
ret
);
ret
=
WinHttpCloseHandle
(
session
);
todo_wine
ok
(
ret
==
TRUE
,
"WinHttpCloseHandle failed on closing session, got %d.
\n
"
,
ret
);
}
START_TEST
(
winhttp
)
{
test_OpenRequest
();
test_SendRequest
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment