Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
114bc2b8
Commit
114bc2b8
authored
Jul 26, 2011
by
Hans Leidekker
Committed by
Alexandre Julliard
Jul 26, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp: Implement IWinHttpRequest::SetRequestHeader.
parent
2c8765e7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
3 deletions
+59
-3
request.c
dlls/winhttp/request.c
+27
-2
winhttp.c
dlls/winhttp/tests/winhttp.c
+32
-1
No files found.
dlls/winhttp/request.c
View file @
114bc2b8
...
...
@@ -2511,8 +2511,33 @@ static HRESULT WINAPI winhttp_request_SetRequestHeader(
BSTR
header
,
BSTR
value
)
{
FIXME
(
"
\n
"
);
return
E_NOTIMPL
;
static
const
WCHAR
fmtW
[]
=
{
'%'
,
's'
,
':'
,
' '
,
'%'
,
's'
,
'\r'
,
'\n'
,
0
};
static
const
WCHAR
emptyW
[]
=
{
0
};
struct
winhttp_request
*
request
=
impl_from_IWinHttpRequest
(
iface
);
DWORD
len
;
WCHAR
*
str
;
BOOL
ret
;
TRACE
(
"%p, %s, %s
\n
"
,
request
,
debugstr_w
(
header
),
debugstr_w
(
value
));
if
(
!
header
)
return
E_INVALIDARG
;
if
(
request
->
state
<
REQUEST_STATE_OPEN
)
{
return
HRESULT_FROM_WIN32
(
ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN
);
}
if
(
request
->
state
>=
REQUEST_STATE_SENT
)
{
return
HRESULT_FROM_WIN32
(
ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND
);
}
len
=
strlenW
(
header
)
+
4
;
if
(
value
)
len
+=
strlenW
(
value
);
if
(
!
(
str
=
heap_alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
E_OUTOFMEMORY
;
sprintfW
(
str
,
fmtW
,
header
,
value
?
value
:
emptyW
);
ret
=
WinHttpAddRequestHeaders
(
request
->
hrequest
,
str
,
len
,
WINHTTP_ADDREQ_FLAG_REPLACE
);
heap_free
(
str
);
if
(
ret
)
return
S_OK
;
return
HRESULT_FROM_WIN32
(
get_last_error
()
);
}
static
DWORD
wait_for_completion
(
struct
winhttp_request
*
request
,
DWORD
timeout
)
...
...
dlls/winhttp/tests/winhttp.c
View file @
114bc2b8
...
...
@@ -2113,13 +2113,19 @@ static void test_IWinHttpRequest(void)
static
const
WCHAR
proxy_serverW
[]
=
{
'p'
,
'r'
,
'o'
,
'x'
,
'y'
,
's'
,
'e'
,
'r'
,
'v'
,
'e'
,
'r'
,
0
};
static
const
WCHAR
bypas_listW
[]
=
{
'b'
,
'y'
,
'p'
,
'a'
,
's'
,
's'
,
'l'
,
'i'
,
's'
,
't'
,
0
};
static
const
WCHAR
connectionW
[]
=
{
'C'
,
'o'
,
'n'
,
'n'
,
'e'
,
'c'
,
't'
,
'i'
,
'o'
,
'n'
,
0
};
static
const
WCHAR
dateW
[]
=
{
'D'
,
'a'
,
't'
,
'e'
,
0
};
HRESULT
hr
;
IWinHttpRequest
*
req
;
BSTR
method
,
url
,
username
,
password
,
response
=
NULL
,
status_text
=
NULL
,
headers
=
NULL
;
BSTR
connection
,
value
=
NULL
;
BSTR
date
,
today
,
connection
,
value
=
NULL
;
VARIANT
async
,
empty
,
timeout
,
body
,
proxy_server
,
bypass_list
;
VARIANT_BOOL
succeeded
;
LONG
status
;
WCHAR
todayW
[
WINHTTP_TIME_FORMAT_BUFSIZE
];
SYSTEMTIME
st
;
GetSystemTime
(
&
st
);
WinHttpTimeFromSystemTime
(
&
st
,
todayW
);
CoInitialize
(
NULL
);
hr
=
CoCreateInstance
(
&
CLSID_WinHttpRequest
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IWinHttpRequest
,
(
void
**
)
&
req
);
...
...
@@ -2248,6 +2254,17 @@ static void test_IWinHttpRequest(void)
hr
=
IWinHttpRequest_GetResponseHeader
(
req
,
connection
,
&
value
);
ok
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND
),
"got %08x
\n
"
,
hr
);
hr
=
IWinHttpRequest_SetRequestHeader
(
req
,
NULL
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %08x
\n
"
,
hr
);
date
=
SysAllocString
(
dateW
);
hr
=
IWinHttpRequest_SetRequestHeader
(
req
,
date
,
NULL
);
ok
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN
),
"got %08x
\n
"
,
hr
);
today
=
SysAllocString
(
todayW
);
hr
=
IWinHttpRequest_SetRequestHeader
(
req
,
date
,
today
);
ok
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN
),
"got %08x
\n
"
,
hr
);
SysFreeString
(
method
);
method
=
SysAllocString
(
method1W
);
SysFreeString
(
url
);
...
...
@@ -2312,6 +2329,12 @@ static void test_IWinHttpRequest(void)
hr
=
IWinHttpRequest_GetResponseHeader
(
req
,
connection
,
&
value
);
ok
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND
),
"got %08x
\n
"
,
hr
);
hr
=
IWinHttpRequest_SetRequestHeader
(
req
,
date
,
today
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
IWinHttpRequest_SetRequestHeader
(
req
,
date
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
IWinHttpRequest_Send
(
req
,
empty
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
...
...
@@ -2370,6 +2393,9 @@ static void test_IWinHttpRequest(void)
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
SysFreeString
(
value
);
hr
=
IWinHttpRequest_SetRequestHeader
(
req
,
date
,
today
);
ok
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND
),
"got %08x
\n
"
,
hr
);
VariantInit
(
&
timeout
);
V_VT
(
&
timeout
)
=
VT_I4
;
V_I4
(
&
timeout
)
=
10
;
...
...
@@ -2428,6 +2454,9 @@ static void test_IWinHttpRequest(void)
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
SysFreeString
(
value
);
hr
=
IWinHttpRequest_SetRequestHeader
(
req
,
date
,
today
);
ok
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND
),
"got %08x
\n
"
,
hr
);
hr
=
IWinHttpRequest_Send
(
req
,
empty
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
...
...
@@ -2444,6 +2473,8 @@ static void test_IWinHttpRequest(void)
SysFreeString
(
url
);
SysFreeString
(
username
);
SysFreeString
(
password
);
SysFreeString
(
date
);
SysFreeString
(
today
);
VariantClear
(
&
proxy_server
);
VariantClear
(
&
bypass_list
);
CoUninitialize
();
...
...
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