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
ac1b5274
Commit
ac1b5274
authored
Jan 04, 2007
by
Rob Shearman
Committed by
Alexandre Julliard
Jan 04, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Use the Content-Length header to work out how much HTTP data there is left to be read
and don't try to read any more than what is available.
parent
cf43b160
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
13 deletions
+37
-13
http.c
dlls/wininet/http.c
+23
-10
internet.c
dlls/wininet/internet.c
+12
-3
internet.h
dlls/wininet/internet.h
+2
-0
No files found.
dlls/wininet/http.c
View file @
ac1b5274
...
...
@@ -605,6 +605,7 @@ BOOL WINAPI HttpEndRequestW(HINTERNET hRequest,
BOOL
rc
=
FALSE
;
LPWININETHTTPREQW
lpwhr
;
INT
responseLen
;
DWORD
dwBufferSize
;
TRACE
(
"-->
\n
"
);
lpwhr
=
(
LPWININETHTTPREQW
)
WININET_GetObject
(
hRequest
);
...
...
@@ -618,6 +619,8 @@ BOOL WINAPI HttpEndRequestW(HINTERNET hRequest,
lpwhr
->
hdr
.
dwFlags
|=
dwFlags
;
lpwhr
->
hdr
.
dwContext
=
dwContext
;
/* We appear to do nothing with lpBuffersOut.. is that correct? */
SendAsyncCallback
(
&
lpwhr
->
hdr
,
lpwhr
->
hdr
.
dwContext
,
INTERNET_STATUS_RECEIVING_RESPONSE
,
NULL
,
0
);
...
...
@@ -631,18 +634,20 @@ BOOL WINAPI HttpEndRequestW(HINTERNET hRequest,
/* process headers here. Is this right? */
HTTP_ProcessHeaders
(
lpwhr
);
/* We appear to do nothing with the buffer.. is that correct? */
dwBufferSize
=
sizeof
(
lpwhr
->
dwContentLength
);
if
(
!
HTTP_HttpQueryInfoW
(
lpwhr
,
HTTP_QUERY_FLAG_NUMBER
|
HTTP_QUERY_CONTENT_LENGTH
,
&
lpwhr
->
dwContentLength
,
&
dwBufferSize
,
NULL
))
lpwhr
->
dwContentLength
=
-
1
;
if
(
!
(
lpwhr
->
hdr
.
dwFlags
&
INTERNET_FLAG_NO_AUTO_REDIRECT
))
{
DWORD
dwCode
,
dwCodeLength
=
sizeof
(
DWORD
)
,
dwIndex
=
0
;
if
(
HTTP_HttpQueryInfoW
(
lpwhr
,
HTTP_QUERY_FLAG_NUMBER
|
HTTP_QUERY_STATUS_CODE
,
&
dwCode
,
&
dwCodeLength
,
&
dwIndex
)
&&
DWORD
dwCode
,
dwCodeLength
=
sizeof
(
DWORD
);
if
(
HTTP_HttpQueryInfoW
(
lpwhr
,
HTTP_QUERY_FLAG_NUMBER
|
HTTP_QUERY_STATUS_CODE
,
&
dwCode
,
&
dwCodeLength
,
NULL
)
&&
(
dwCode
==
302
||
dwCode
==
301
))
{
WCHAR
szNewLocation
[
2048
];
DWORD
dwBufferSize
=
2048
;
dwIndex
=
0
;
if
(
HTTP_HttpQueryInfoW
(
lpwhr
,
HTTP_QUERY_LOCATION
,
szNewLocation
,
&
dwBufferSize
,
&
dwIndex
))
dwBufferSize
=
2048
;
if
(
HTTP_HttpQueryInfoW
(
lpwhr
,
HTTP_QUERY_LOCATION
,
szNewLocation
,
&
dwBufferSize
,
NULL
))
{
static
const
WCHAR
szGET
[]
=
{
'G'
,
'E'
,
'T'
,
0
};
/* redirects are always GETs */
...
...
@@ -2255,6 +2260,7 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
char
*
ascii_req
;
loop_next
=
FALSE
;
lpwhr
->
dwContentRead
=
0
;
if
(
TRACE_ON
(
wininet
))
{
...
...
@@ -2311,6 +2317,8 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
if
(
bEndRequest
)
{
DWORD
dwBufferSize
;
INTERNET_SendCallback
(
&
lpwhr
->
hdr
,
lpwhr
->
hdr
.
dwContext
,
INTERNET_STATUS_RECEIVING_RESPONSE
,
NULL
,
0
);
...
...
@@ -2327,14 +2335,19 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
HTTP_ProcessHeaders
(
lpwhr
);
dwBufferSize
=
sizeof
(
lpwhr
->
dwContentLength
);
if
(
!
HTTP_HttpQueryInfoW
(
lpwhr
,
HTTP_QUERY_FLAG_NUMBER
|
HTTP_QUERY_CONTENT_LENGTH
,
&
lpwhr
->
dwContentLength
,
&
dwBufferSize
,
NULL
))
lpwhr
->
dwContentLength
=
-
1
;
if
(
!
(
lpwhr
->
hdr
.
dwFlags
&
INTERNET_FLAG_NO_AUTO_REDIRECT
)
&&
bSuccess
)
{
DWORD
dwCode
,
dwCodeLength
=
sizeof
(
DWORD
)
,
dwIndex
=
0
;
DWORD
dwCode
,
dwCodeLength
=
sizeof
(
DWORD
);
WCHAR
szNewLocation
[
2048
];
DWORD
dwBufferSize
=
2048
;
if
(
HTTP_HttpQueryInfoW
(
lpwhr
,
HTTP_QUERY_FLAG_NUMBER
|
HTTP_QUERY_STATUS_CODE
,
&
dwCode
,
&
dwCodeLength
,
&
dwIndex
)
&&
dwBufferSize
=
2048
;
if
(
HTTP_HttpQueryInfoW
(
lpwhr
,
HTTP_QUERY_FLAG_NUMBER
|
HTTP_QUERY_STATUS_CODE
,
&
dwCode
,
&
dwCodeLength
,
NULL
)
&&
(
dwCode
==
HTTP_STATUS_REDIRECT
||
dwCode
==
HTTP_STATUS_MOVED
)
&&
HTTP_HttpQueryInfoW
(
lpwhr
,
HTTP_QUERY_LOCATION
,
szNewLocation
,
&
dwBufferSize
,
&
dwIndex
))
HTTP_HttpQueryInfoW
(
lpwhr
,
HTTP_QUERY_LOCATION
,
szNewLocation
,
&
dwBufferSize
,
NULL
))
{
INTERNET_SendCallback
(
&
lpwhr
->
hdr
,
lpwhr
->
hdr
.
dwContext
,
INTERNET_STATUS_REDIRECT
,
szNewLocation
,
...
...
dlls/wininet/internet.c
View file @
ac1b5274
...
...
@@ -1690,19 +1690,27 @@ static BOOL INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh, LPVOID lpBuffer,
{
BOOL
retval
=
FALSE
;
int
nSocket
=
-
1
;
int
bytes_read
;
LPWININETHTTPREQW
lpwhr
;
/* FIXME: this should use NETCON functions! */
switch
(
lpwh
->
htype
)
{
case
WH_HHTTPREQ
:
if
(
!
NETCON_recv
(
&
((
LPWININETHTTPREQW
)
lpwh
)
->
netConnection
,
lpBuffer
,
dwNumOfBytesToRead
,
bWait
?
MSG_WAITALL
:
0
,
(
int
*
)
pdwNumOfBytesRead
))
lpwhr
=
(
LPWININETHTTPREQW
)
lpwh
;
if
(
!
NETCON_recv
(
&
lpwhr
->
netConnection
,
lpBuffer
,
min
(
dwNumOfBytesToRead
,
lpwhr
->
dwContentLength
-
lpwhr
->
dwContentRead
),
bWait
?
MSG_WAITALL
:
0
,
&
bytes_read
))
{
*
pdwNumOfBytesRead
=
0
;
retval
=
TRUE
;
/* Under windows, it seems to return 0 even if nothing was read... */
}
else
{
lpwhr
->
dwContentRead
+=
bytes_read
;
*
pdwNumOfBytesRead
=
bytes_read
;
retval
=
TRUE
;
}
break
;
case
WH_HFILE
:
...
...
@@ -3216,7 +3224,8 @@ BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
{
case
WH_HHTTPREQ
:
if
(
!
NETCON_recv
(
&
lpwhr
->
netConnection
,
buffer
,
4048
,
MSG_PEEK
,
(
int
*
)
lpdwNumberOfBytesAvailble
))
min
(
sizeof
(
buffer
),
lpwhr
->
dwContentLength
-
lpwhr
->
dwContentRead
),
MSG_PEEK
,
(
int
*
)
lpdwNumberOfBytesAvailble
))
{
SetLastError
(
ERROR_NO_MORE_FILES
);
retval
=
FALSE
;
...
...
dlls/wininet/internet.h
View file @
ac1b5274
...
...
@@ -197,6 +197,8 @@ typedef struct
WININET_NETCONNECTION
netConnection
;
LPWSTR
lpszVersion
;
LPWSTR
lpszStatusText
;
DWORD
dwContentLength
;
/* total number of bytes to be read */
DWORD
dwContentRead
;
/* bytes of the content read so far */
HTTPHEADERW
*
pCustHeaders
;
DWORD
nCustHeaders
;
}
WININETHTTPREQW
,
*
LPWININETHTTPREQW
;
...
...
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