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
e2f690a0
Commit
e2f690a0
authored
May 02, 2008
by
Hans Leidekker
Committed by
Alexandre Julliard
May 05, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Don't add the user agent header until HttpSendRequest is called.
parent
c6da2a0b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
14 deletions
+70
-14
http.c
dlls/wininet/http.c
+13
-14
http.c
dlls/wininet/tests/http.c
+57
-0
No files found.
dlls/wininet/http.c
View file @
e2f690a0
...
...
@@ -1965,20 +1965,6 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
if
(
NULL
!=
hIC
->
lpszProxy
&&
hIC
->
lpszProxy
[
0
]
!=
0
)
HTTP_DealWithProxy
(
hIC
,
lpwhs
,
lpwhr
);
if
(
hIC
->
lpszAgent
)
{
WCHAR
*
agent_header
;
static
const
WCHAR
user_agent
[]
=
{
'U'
,
's'
,
'e'
,
'r'
,
'-'
,
'A'
,
'g'
,
'e'
,
'n'
,
't'
,
':'
,
' '
,
'%'
,
's'
,
'\r'
,
'\n'
,
0
};
len
=
strlenW
(
hIC
->
lpszAgent
)
+
strlenW
(
user_agent
);
agent_header
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
);
sprintfW
(
agent_header
,
user_agent
,
hIC
->
lpszAgent
);
HTTP_HttpAddRequestHeadersW
(
lpwhr
,
agent_header
,
strlenW
(
agent_header
),
HTTP_ADDREQ_FLAG_ADD
);
HeapFree
(
GetProcessHeap
(),
0
,
agent_header
);
}
Host
=
HTTP_GetHeader
(
lpwhr
,
szHost
);
len
=
lstrlenW
(
Host
->
lpszValue
)
+
strlenW
(
szUrlForm
);
...
...
@@ -3175,6 +3161,19 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
sprintfW
(
contentLengthStr
,
szContentLength
,
dwContentLength
);
HTTP_HttpAddRequestHeadersW
(
lpwhr
,
contentLengthStr
,
-
1L
,
HTTP_ADDREQ_FLAG_ADD
|
HTTP_ADDHDR_FLAG_REPLACE
);
}
if
(
lpwhr
->
lpHttpSession
->
lpAppInfo
->
lpszAgent
)
{
WCHAR
*
agent_header
;
static
const
WCHAR
user_agent
[]
=
{
'U'
,
's'
,
'e'
,
'r'
,
'-'
,
'A'
,
'g'
,
'e'
,
'n'
,
't'
,
':'
,
' '
,
'%'
,
's'
,
'\r'
,
'\n'
,
0
};
int
len
;
len
=
strlenW
(
lpwhr
->
lpHttpSession
->
lpAppInfo
->
lpszAgent
)
+
strlenW
(
user_agent
);
agent_header
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
sprintfW
(
agent_header
,
user_agent
,
lpwhr
->
lpHttpSession
->
lpAppInfo
->
lpszAgent
);
HTTP_HttpAddRequestHeadersW
(
lpwhr
,
agent_header
,
strlenW
(
agent_header
),
HTTP_ADDREQ_FLAG_ADD_IF_NEW
);
HeapFree
(
GetProcessHeap
(),
0
,
agent_header
);
}
do
{
...
...
dlls/wininet/tests/http.c
View file @
e2f690a0
...
...
@@ -1686,6 +1686,62 @@ static void test_http_connection(void)
CloseHandle
(
hThread
);
}
static
void
test_user_agent_header
(
void
)
{
HINTERNET
ses
,
con
,
req
;
DWORD
size
,
err
;
char
buffer
[
64
];
BOOL
ret
;
ses
=
InternetOpen
(
"Gizmo5"
,
INTERNET_OPEN_TYPE_DIRECT
,
NULL
,
NULL
,
0
);
ok
(
ses
!=
NULL
,
"InternetOpen failed
\n
"
);
con
=
InternetConnect
(
ses
,
"www.winehq.org"
,
80
,
NULL
,
NULL
,
INTERNET_SERVICE_HTTP
,
0
,
0
);
ok
(
con
!=
NULL
,
"InternetConnect failed
\n
"
);
req
=
HttpOpenRequest
(
con
,
"GET"
,
"/"
,
"HTTP/1.0"
,
NULL
,
NULL
,
0
,
0
);
ok
(
req
!=
NULL
,
"HttpOpenRequest failed
\n
"
);
size
=
sizeof
(
buffer
);
ret
=
HttpQueryInfo
(
req
,
HTTP_QUERY_USER_AGENT
|
HTTP_QUERY_FLAG_REQUEST_HEADERS
,
buffer
,
&
size
,
NULL
);
err
=
GetLastError
();
ok
(
!
ret
,
"HttpQueryInfo succeeded
\n
"
);
ok
(
err
==
ERROR_HTTP_HEADER_NOT_FOUND
,
"expected ERROR_HTTP_HEADER_NOT_FOUND, got %u
\n
"
,
err
);
ret
=
HttpAddRequestHeaders
(
req
,
"User-Agent: Gizmo Project
\r\n
"
,
~
0UL
,
HTTP_ADDREQ_FLAG_ADD_IF_NEW
);
ok
(
ret
,
"HttpAddRequestHeaders succeeded
\n
"
);
size
=
sizeof
(
buffer
);
ret
=
HttpQueryInfo
(
req
,
HTTP_QUERY_USER_AGENT
|
HTTP_QUERY_FLAG_REQUEST_HEADERS
,
buffer
,
&
size
,
NULL
);
err
=
GetLastError
();
ok
(
ret
,
"HttpQueryInfo failed
\n
"
);
ok
(
err
==
ERROR_HTTP_HEADER_NOT_FOUND
,
"expected ERROR_HTTP_HEADER_NOT_FOUND, got %u
\n
"
,
err
);
InternetCloseHandle
(
req
);
req
=
HttpOpenRequest
(
con
,
"GET"
,
"/"
,
"HTTP/1.0"
,
NULL
,
NULL
,
0
,
0
);
ok
(
req
!=
NULL
,
"HttpOpenRequest failed
\n
"
);
size
=
sizeof
(
buffer
);
ret
=
HttpQueryInfo
(
req
,
HTTP_QUERY_ACCEPT
|
HTTP_QUERY_FLAG_REQUEST_HEADERS
,
buffer
,
&
size
,
NULL
);
err
=
GetLastError
();
ok
(
!
ret
,
"HttpQueryInfo succeeded
\n
"
);
ok
(
err
==
ERROR_HTTP_HEADER_NOT_FOUND
,
"expected ERROR_HTTP_HEADER_NOT_FOUND, got %u
\n
"
,
err
);
ret
=
HttpAddRequestHeaders
(
req
,
"Accept: audio/*, image/*, text/*
\r\n
User-Agent: Gizmo Project
\r\n
"
,
~
0UL
,
HTTP_ADDREQ_FLAG_ADD_IF_NEW
);
ok
(
ret
,
"HttpAddRequestHeaders failed
\n
"
);
buffer
[
0
]
=
0
;
size
=
sizeof
(
buffer
);
ret
=
HttpQueryInfo
(
req
,
HTTP_QUERY_ACCEPT
|
HTTP_QUERY_FLAG_REQUEST_HEADERS
,
buffer
,
&
size
,
NULL
);
ok
(
ret
,
"HttpQueryInfo failed: %u
\n
"
,
GetLastError
());
ok
(
!
strcmp
(
buffer
,
"audio/*, image/*, text/*"
),
"got '%s' expected 'audio/*, image/*, text/*'
\n
"
,
buffer
);
InternetCloseHandle
(
req
);
InternetCloseHandle
(
con
);
InternetCloseHandle
(
ses
);
}
#define STATUS_STRING(status) \
memcpy(status_string[status], #status, sizeof(CHAR) * \
(strlen(#status) < MAX_STATUS_NAME ? \
...
...
@@ -1759,4 +1815,5 @@ START_TEST(http)
HttpSendRequestEx_test
();
HttpHeaders_test
();
test_http_connection
();
test_user_agent_header
();
}
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