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
c4001170
Commit
c4001170
authored
Jul 02, 2012
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 02, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Try harder to reuse connection after authorization.
parent
8fc1c948
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
23 deletions
+47
-23
http.c
dlls/wininet/http.c
+47
-23
No files found.
dlls/wininet/http.c
View file @
c4001170
...
...
@@ -219,6 +219,7 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t*, DWORD, LPVOID, LPDWORD, LPDWOR
static
LPWSTR
HTTP_GetRedirectURL
(
http_request_t
*
req
,
LPCWSTR
lpszUrl
);
static
UINT
HTTP_DecodeBase64
(
LPCWSTR
base64
,
LPSTR
bin
);
static
BOOL
HTTP_VerifyValidHeader
(
http_request_t
*
req
,
LPCWSTR
field
);
static
BOOL
drain_content
(
http_request_t
*
,
BOOL
);
static
CRITICAL_SECTION
connection_pool_cs
;
static
CRITICAL_SECTION_DEBUG
connection_pool_debug
=
...
...
@@ -1906,22 +1907,6 @@ static void http_release_netconn(http_request_t *req, BOOL reuse)
INTERNET_STATUS_CONNECTION_CLOSED
,
0
,
0
);
}
static
void
drain_content
(
http_request_t
*
req
)
{
BOOL
try_reuse
;
if
(
!
req
->
netconn
)
return
;
if
(
req
->
contentLength
==
-
1
)
try_reuse
=
FALSE
;
else
if
(
!
strcmpW
(
req
->
verb
,
szHEAD
))
try_reuse
=
TRUE
;
else
try_reuse
=
req
->
data_stream
->
vtbl
->
drain_content
(
req
->
data_stream
,
req
);
http_release_netconn
(
req
,
try_reuse
);
}
static
BOOL
HTTP_KeepAlive
(
http_request_t
*
request
)
{
WCHAR
szVersion
[
10
];
...
...
@@ -1951,7 +1936,7 @@ static void HTTPREQ_CloseConnection(object_header_t *hdr)
{
http_request_t
*
req
=
(
http_request_t
*
)
hdr
;
drain_content
(
req
);
http_release_netconn
(
req
,
drain_content
(
req
,
FALSE
)
);
}
static
DWORD
HTTPREQ_QueryOption
(
object_header_t
*
hdr
,
DWORD
option
,
void
*
buffer
,
DWORD
*
size
,
BOOL
unicode
)
...
...
@@ -2757,6 +2742,39 @@ static DWORD HTTPREQ_Read(http_request_t *req, void *buffer, DWORD size, DWORD *
return
res
;
}
static
BOOL
drain_content
(
http_request_t
*
req
,
BOOL
blocking
)
{
BOOL
ret
;
if
(
!
req
->
netconn
||
req
->
contentLength
==
-
1
)
return
FALSE
;
if
(
!
strcmpW
(
req
->
verb
,
szHEAD
))
return
TRUE
;
if
(
!
blocking
)
return
req
->
data_stream
->
vtbl
->
drain_content
(
req
->
data_stream
,
req
);
EnterCriticalSection
(
&
req
->
read_section
);
while
(
1
)
{
DWORD
bytes_read
,
res
;
BYTE
buf
[
4096
];
res
=
HTTPREQ_Read
(
req
,
buf
,
sizeof
(
buf
),
&
bytes_read
,
TRUE
);
if
(
res
!=
ERROR_SUCCESS
)
{
ret
=
FALSE
;
break
;
}
if
(
!
bytes_read
)
{
ret
=
TRUE
;
break
;
}
}
LeaveCriticalSection
(
&
req
->
read_section
);
return
ret
;
}
static
DWORD
HTTPREQ_ReadFile
(
object_header_t
*
hdr
,
void
*
buffer
,
DWORD
size
,
DWORD
*
read
)
{
...
...
@@ -4769,10 +4787,8 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
char
*
ascii_req
;
loop_next
=
FALSE
;
reusing_connection
=
request
->
netconn
!=
NULL
;
/* like native, just in case the caller forgot to call InternetReadFile
* for all the data */
drain_content
(
request
);
if
(
redirected
)
{
request
->
contentLength
=
~
0u
;
request
->
bytesToWrite
=
0
;
...
...
@@ -4807,7 +4823,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
TRACE
(
"Request header -> %s
\n
"
,
debugstr_w
(
requestString
)
);
if
((
res
=
open_http_connection
(
request
,
&
reusing_connection
))
!=
ERROR_SUCCESS
)
if
(
!
reusing_connection
&&
(
res
=
open_http_connection
(
request
,
&
reusing_connection
))
!=
ERROR_SUCCESS
)
break
;
/* send the request as ASCII, tack on the optional data */
...
...
@@ -4895,7 +4911,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
heap_free
(
request
->
verb
);
request
->
verb
=
heap_strdupW
(
szGET
);
}
drain_content
(
request
);
http_release_netconn
(
request
,
drain_content
(
request
,
FALSE
)
);
if
((
new_url
=
HTTP_GetRedirectURL
(
request
,
szNewLocation
)))
{
INTERNET_SendCallback
(
&
request
->
hdr
,
request
->
hdr
.
dwContext
,
INTERNET_STATUS_REDIRECT
,
...
...
@@ -4928,6 +4944,10 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
Host
->
lpszValue
))
{
heap_free
(
requestString
);
if
(
!
drain_content
(
request
,
TRUE
))
{
FIXME
(
"Could not drain content
\n
"
);
http_release_netconn
(
request
,
FALSE
);
}
loop_next
=
TRUE
;
break
;
}
...
...
@@ -4950,6 +4970,10 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
request
->
session
->
appInfo
->
proxyPassword
,
NULL
))
{
if
(
!
drain_content
(
request
,
TRUE
))
{
FIXME
(
"Could not drain content
\n
"
);
http_release_netconn
(
request
,
FALSE
);
}
loop_next
=
TRUE
;
break
;
}
...
...
@@ -5064,7 +5088,7 @@ static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_
heap_free
(
request
->
verb
);
request
->
verb
=
heap_strdupW
(
szGET
);
}
drain_content
(
request
);
http_release_netconn
(
request
,
drain_content
(
request
,
FALSE
)
);
if
((
new_url
=
HTTP_GetRedirectURL
(
request
,
szNewLocation
)))
{
INTERNET_SendCallback
(
&
request
->
hdr
,
request
->
hdr
.
dwContext
,
INTERNET_STATUS_REDIRECT
,
...
...
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