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
4227dfaa
Commit
4227dfaa
authored
May 17, 2016
by
Jacek Caban
Committed by
Alexandre Julliard
May 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Store request URL in req_file_t.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ce4bdcd0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
35 deletions
+48
-35
http.c
dlls/wininet/http.c
+46
-35
internet.c
dlls/wininet/internet.c
+1
-0
internet.h
dlls/wininet/internet.h
+1
-0
No files found.
dlls/wininet/http.c
View file @
4227dfaa
...
...
@@ -1873,14 +1873,14 @@ static DWORD HTTP_ResolveName(http_request_t *request)
return
ERROR_SUCCESS
;
}
static
BOOL
HTTP_GetRequestURL
(
http_request_t
*
req
,
LPWSTR
buf
)
static
WCHAR
*
compose_request_url
(
http_request_t
*
req
)
{
static
const
WCHAR
http
[]
=
{
'h'
,
't'
,
't'
,
'p'
,
':'
,
'/'
,
'/'
,
0
};
static
const
WCHAR
https
[]
=
{
'h'
,
't'
,
't'
,
'p'
,
's'
,
':'
,
'/'
,
'/'
,
0
};
static
const
WCHAR
slash
[]
=
{
'/'
,
0
};
LPHTTPHEADERW
host_header
;
const
WCHAR
*
host
;
LPCWSTR
scheme
;
const
WCHAR
*
host
,
*
scheme
;
WCHAR
*
buf
,
*
ptr
;
size_t
len
;
EnterCriticalSection
(
&
req
->
headers_section
);
...
...
@@ -1888,18 +1888,30 @@ static BOOL HTTP_GetRequestURL(http_request_t *req, LPWSTR buf)
if
(
host_header
)
host
=
host_header
->
lpszValue
;
else
host
=
req
->
server
->
canon_host_port
;
if
(
req
->
hdr
.
dwFlags
&
INTERNET_FLAG_SECURE
)
if
(
req
->
server
->
is_https
)
scheme
=
https
;
else
scheme
=
http
;
strcpyW
(
buf
,
scheme
);
strcatW
(
buf
,
host
);
if
(
req
->
path
[
0
]
!=
'/'
)
strcatW
(
buf
,
slash
);
strcatW
(
buf
,
req
->
path
);
len
=
strlenW
(
scheme
)
+
strlenW
(
host
)
+
(
req
->
path
[
0
]
!=
'/'
?
1
:
0
)
+
strlenW
(
req
->
path
);
ptr
=
buf
=
heap_alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
if
(
buf
)
{
strcpyW
(
ptr
,
scheme
);
ptr
+=
strlenW
(
ptr
);
strcpyW
(
ptr
,
host
);
ptr
+=
strlenW
(
ptr
);
if
(
req
->
path
[
0
]
!=
'/'
)
*
ptr
++
=
'/'
;
strcpyW
(
ptr
,
req
->
path
);
ptr
+=
strlenW
(
ptr
);
*
ptr
=
0
;
}
LeaveCriticalSection
(
&
req
->
headers_section
);
return
TRUE
;
return
buf
;
}
...
...
@@ -2158,27 +2170,29 @@ static DWORD HTTPREQ_QueryOption(object_header_t *hdr, DWORD option, void *buffe
case
INTERNET_OPTION_CACHE_TIMESTAMPS
:
{
INTERNET_CACHE_ENTRY_INFOW
*
info
;
INTERNET_CACHE_TIMESTAMPS
*
ts
=
buffer
;
WCHAR
url
[
INTERNET_MAX_URL_LENGTH
];
DWORD
nbytes
,
error
;
BOOL
ret
;
TRACE
(
"INTERNET_OPTION_CACHE_TIMESTAMPS
\n
"
);
if
(
!
req
->
req_file
)
return
ERROR_FILE_NOT_FOUND
;
if
(
*
size
<
sizeof
(
*
ts
))
{
*
size
=
sizeof
(
*
ts
);
return
ERROR_INSUFFICIENT_BUFFER
;
}
nbytes
=
0
;
HTTP_GetRequestURL
(
req
,
url
);
ret
=
GetUrlCacheEntryInfoW
(
url
,
NULL
,
&
nbytes
);
ret
=
GetUrlCacheEntryInfoW
(
req
->
req_file
->
url
,
NULL
,
&
nbytes
);
error
=
GetLastError
();
if
(
!
ret
&&
error
==
ERROR_INSUFFICIENT_BUFFER
)
{
if
(
!
(
info
=
heap_alloc
(
nbytes
)))
return
ERROR_OUTOFMEMORY
;
GetUrlCacheEntryInfoW
(
url
,
info
,
&
nbytes
);
GetUrlCacheEntryInfoW
(
req
->
req_file
->
url
,
info
,
&
nbytes
);
ts
->
ftExpires
=
info
->
ExpireTime
;
ts
->
ftLastModified
=
info
->
LastModifiedTime
;
...
...
@@ -2367,29 +2381,25 @@ static DWORD HTTPREQ_SetOption(object_header_t *hdr, DWORD option, void *buffer,
static
void
commit_cache_entry
(
http_request_t
*
req
)
{
WCHAR
url
[
INTERNET_MAX_URL_LENGTH
];
WCHAR
*
header
;
DWORD
header_len
;
BOOL
res
;
TRACE
(
"%p
\n
"
,
req
);
CloseHandle
(
req
->
hCacheFile
);
req
->
hCacheFile
=
NULL
;
if
(
HTTP_GetRequestURL
(
req
,
url
))
{
WCHAR
*
header
;
DWORD
header_len
;
BOOL
res
;
header
=
build_response_header
(
req
,
TRUE
);
header_len
=
(
header
?
strlenW
(
header
)
:
0
);
res
=
CommitUrlCacheEntryW
(
url
,
req
->
req_file
->
file_name
,
req
->
expires
,
req
->
last_modified
,
NORMAL_CACHE_ENTRY
,
header
,
header_len
,
NULL
,
0
);
if
(
res
)
req
->
req_file
->
is_committed
=
TRUE
;
else
WARN
(
"CommitUrlCacheEntry failed: %u
\n
"
,
GetLastError
());
heap_free
(
header
);
}
header
=
build_response_header
(
req
,
TRUE
);
header_len
=
(
header
?
strlenW
(
header
)
:
0
);
res
=
CommitUrlCacheEntryW
(
req
->
req_file
->
url
,
req
->
req_file
->
file_name
,
req
->
expires
,
req
->
last_modified
,
NORMAL_CACHE_ENTRY
,
header
,
header_len
,
NULL
,
0
);
if
(
res
)
req
->
req_file
->
is_committed
=
TRUE
;
else
WARN
(
"CommitUrlCacheEntry failed: %u
\n
"
,
GetLastError
());
heap_free
(
header
);
}
static
void
create_cache_entry
(
http_request_t
*
req
)
...
...
@@ -2397,8 +2407,8 @@ static void create_cache_entry(http_request_t *req)
static
const
WCHAR
no_cacheW
[]
=
{
'n'
,
'o'
,
'-'
,
'c'
,
'a'
,
'c'
,
'h'
,
'e'
,
0
};
static
const
WCHAR
no_storeW
[]
=
{
'n'
,
'o'
,
'-'
,
's'
,
't'
,
'o'
,
'r'
,
'e'
,
0
};
WCHAR
url
[
INTERNET_MAX_URL_LENGTH
];
WCHAR
file_name
[
MAX_PATH
+
1
];
WCHAR
*
url
;
BOOL
b
=
TRUE
;
/* FIXME: We should free previous cache file earlier */
...
...
@@ -2455,8 +2465,8 @@ static void create_cache_entry(http_request_t *req)
FIXME
(
"INTERNET_FLAG_NEED_FILE is not supported correctly
\n
"
);
}
b
=
HTTP_GetRequestURL
(
req
,
url
);
if
(
!
b
)
{
url
=
compose_request_url
(
req
);
if
(
!
url
)
{
WARN
(
"Could not get URL
\n
"
);
return
;
}
...
...
@@ -2468,6 +2478,7 @@ static void create_cache_entry(http_request_t *req)
}
create_req_file
(
file_name
,
&
req
->
req_file
);
req
->
req_file
->
url
=
url
;
req
->
hCacheFile
=
CreateFileW
(
file_name
,
GENERIC_WRITE
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
...
...
dlls/wininet/internet.c
View file @
4227dfaa
...
...
@@ -3901,6 +3901,7 @@ void req_file_release(req_file_t *req_file)
if
(
req_file
->
file_handle
&&
req_file
->
file_handle
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
req_file
->
file_handle
);
heap_free
(
req_file
->
file_name
);
heap_free
(
req_file
->
url
);
heap_free
(
req_file
);
}
...
...
dlls/wininet/internet.h
View file @
4227dfaa
...
...
@@ -268,6 +268,7 @@ typedef struct
LONG
ref
;
HANDLE
file_handle
;
WCHAR
*
file_name
;
WCHAR
*
url
;
BOOL
is_committed
;
}
req_file_t
;
...
...
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