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
e0e31478
Commit
e0e31478
authored
Feb 09, 2004
by
Lionel Ulmer
Committed by
Alexandre Julliard
Feb 09, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented proper asynchronous InternetOpenUrl handling.
parent
f9ce2138
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
125 additions
and
39 deletions
+125
-39
http.c
dlls/wininet/http.c
+21
-28
internet.c
dlls/wininet/internet.c
+85
-11
internet.h
dlls/wininet/internet.h
+19
-0
No files found.
dlls/wininet/http.c
View file @
e0e31478
...
...
@@ -89,13 +89,6 @@ BOOL HTTP_InsertCustomHeader(LPWININETHTTPREQA lpwhr, LPHTTPHEADERA lpHdr);
INT
HTTP_GetCustomHeaderIndex
(
LPWININETHTTPREQA
lpwhr
,
LPCSTR
lpszField
);
BOOL
HTTP_DeleteCustomHeader
(
LPWININETHTTPREQA
lpwhr
,
INT
index
);
inline
static
LPSTR
HTTP_strdup
(
LPCSTR
str
)
{
LPSTR
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
str
)
+
1
);
if
(
ret
)
strcpy
(
ret
,
str
);
return
ret
;
}
/***********************************************************************
* HttpAddRequestHeadersA (WININET.@)
*
...
...
@@ -131,7 +124,7 @@ BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
return
TRUE
;
TRACE
(
"copying header: %s
\n
"
,
lpszHeader
);
buffer
=
HTTP
_strdup
(
lpszHeader
);
buffer
=
WININET
_strdup
(
lpszHeader
);
lpszStart
=
buffer
;
do
...
...
@@ -252,14 +245,14 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
workRequest
.
asyncall
=
HTTPOPENREQUESTA
;
workRequest
.
handle
=
hHttpSession
;
req
=
&
workRequest
.
u
.
HttpOpenRequestA
;
req
->
lpszVerb
=
HTTP
_strdup
(
lpszVerb
);
req
->
lpszObjectName
=
HTTP
_strdup
(
lpszObjectName
);
req
->
lpszVerb
=
WININET
_strdup
(
lpszVerb
);
req
->
lpszObjectName
=
WININET
_strdup
(
lpszObjectName
);
if
(
lpszVersion
)
req
->
lpszVersion
=
HTTP
_strdup
(
lpszVersion
);
req
->
lpszVersion
=
WININET
_strdup
(
lpszVersion
);
else
req
->
lpszVersion
=
0
;
if
(
lpszReferrer
)
req
->
lpszReferrer
=
HTTP
_strdup
(
lpszReferrer
);
req
->
lpszReferrer
=
WININET
_strdup
(
lpszReferrer
);
else
req
->
lpszReferrer
=
0
;
req
->
lpszAcceptTypes
=
lpszAcceptTypes
;
...
...
@@ -535,7 +528,7 @@ static BOOL HTTP_DealWithProxy( LPWININETAPPINFOA hIC,
HeapFree
(
GetProcessHeap
(),
0
,
lpwhr
->
lpszPath
);
lpwhr
->
lpszPath
=
url
;
/* FIXME: Do I have to free lpwhs->lpszServerName here ? */
lpwhs
->
lpszServerName
=
HTTP
_strdup
(
UrlComponents
.
lpszHostName
);
lpwhs
->
lpszServerName
=
WININET
_strdup
(
UrlComponents
.
lpszHostName
);
lpwhs
->
nServerPort
=
UrlComponents
.
nPort
;
return
TRUE
;
...
...
@@ -622,9 +615,9 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
}
if
(
NULL
==
lpszVerb
)
lpwhr
->
lpszVerb
=
HTTP
_strdup
(
"GET"
);
lpwhr
->
lpszVerb
=
WININET
_strdup
(
"GET"
);
else
if
(
strlen
(
lpszVerb
))
lpwhr
->
lpszVerb
=
HTTP
_strdup
(
lpszVerb
);
lpwhr
->
lpszVerb
=
WININET
_strdup
(
lpszVerb
);
if
(
NULL
!=
lpszReferrer
&&
strlen
(
lpszReferrer
))
{
...
...
@@ -638,9 +631,9 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
InternetCrackUrlA
(
lpszReferrer
,
0
,
0
,
&
UrlComponents
);
if
(
strlen
(
UrlComponents
.
lpszHostName
))
lpwhr
->
lpszHostName
=
HTTP
_strdup
(
UrlComponents
.
lpszHostName
);
lpwhr
->
lpszHostName
=
WININET
_strdup
(
UrlComponents
.
lpszHostName
);
}
else
{
lpwhr
->
lpszHostName
=
HTTP
_strdup
(
lpwhs
->
lpszServerName
);
lpwhr
->
lpszHostName
=
WININET
_strdup
(
lpwhs
->
lpszServerName
);
}
if
(
NULL
!=
hIC
->
lpszProxy
&&
hIC
->
lpszProxy
[
0
]
!=
0
)
HTTP_DealWithProxy
(
hIC
,
lpwhs
,
lpwhr
);
...
...
@@ -996,7 +989,7 @@ BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
workRequest
.
handle
=
hHttpRequest
;
req
=
&
workRequest
.
u
.
HttpSendRequestA
;
if
(
lpszHeaders
)
req
->
lpszHeader
=
HTTP
_strdup
(
lpszHeaders
);
req
->
lpszHeader
=
WININET
_strdup
(
lpszHeaders
);
else
req
->
lpszHeader
=
0
;
req
->
dwHeaderLength
=
dwHeaderLength
;
...
...
@@ -1109,15 +1102,15 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQA lpwhr, LPCSTR lpszUrl, LPCSTR
if
(
NULL
!=
lpwhs
->
lpszServerName
)
HeapFree
(
GetProcessHeap
(),
0
,
lpwhs
->
lpszServerName
);
lpwhs
->
lpszServerName
=
HTTP
_strdup
(
hostName
);
lpwhs
->
lpszServerName
=
WININET
_strdup
(
hostName
);
if
(
NULL
!=
lpwhs
->
lpszUserName
)
HeapFree
(
GetProcessHeap
(),
0
,
lpwhs
->
lpszUserName
);
lpwhs
->
lpszUserName
=
HTTP
_strdup
(
userName
);
lpwhs
->
lpszUserName
=
WININET
_strdup
(
userName
);
lpwhs
->
nServerPort
=
urlComponents
.
nPort
;
if
(
NULL
!=
lpwhr
->
lpszHostName
)
HeapFree
(
GetProcessHeap
(),
0
,
lpwhr
->
lpszHostName
);
lpwhr
->
lpszHostName
=
HTTP
_strdup
(
hostName
);
lpwhr
->
lpszHostName
=
WININET
_strdup
(
hostName
);
SendAsyncCallback
(
hIC
,
lpwhs
,
lpwhr
->
hdr
.
dwContext
,
INTERNET_STATUS_RESOLVING_NAME
,
...
...
@@ -1238,7 +1231,7 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
/* If we don't have a path we set it to root */
if
(
NULL
==
lpwhr
->
lpszPath
)
lpwhr
->
lpszPath
=
HTTP
_strdup
(
"/"
);
lpwhr
->
lpszPath
=
WININET
_strdup
(
"/"
);
if
(
strncmp
(
lpwhr
->
lpszPath
,
"http://"
,
sizeof
(
"http://"
)
-
1
)
!=
0
&&
lpwhr
->
lpszPath
[
0
]
!=
'/'
)
/* not an absolute path ?? --> fix it !! */
...
...
@@ -1270,7 +1263,7 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
*/
if
((
len
>
2
)
&&
(
memcmp
(
lpszHeaders
+
(
len
-
2
),
"
\r\n
"
,
2
)
==
0
))
{
lpszHeaders_r_n
=
HTTP
_strdup
(
lpszHeaders
);
lpszHeaders_r_n
=
WININET
_strdup
(
lpszHeaders
);
}
else
{
...
...
@@ -1617,9 +1610,9 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
FIXME
(
"Proxy bypass is ignored.
\n
"
);
}
if
(
NULL
!=
lpszServerName
)
lpwhs
->
lpszServerName
=
HTTP
_strdup
(
lpszServerName
);
lpwhs
->
lpszServerName
=
WININET
_strdup
(
lpszServerName
);
if
(
NULL
!=
lpszUserName
)
lpwhs
->
lpszUserName
=
HTTP
_strdup
(
lpszUserName
);
lpwhs
->
lpszUserName
=
WININET
_strdup
(
lpszUserName
);
lpwhs
->
nServerPort
=
nServerPort
;
if
(
hIC
->
lpfnStatusCB
)
...
...
@@ -1976,7 +1969,7 @@ BOOL HTTP_ProcessHeader(LPWININETHTTPREQA lpwhr, LPCSTR field, LPCSTR value, DWO
if
(
!
lpwhr
->
StdHeaders
[
index
].
lpszField
)
{
lphttpHdr
->
lpszField
=
HTTP
_strdup
(
field
);
lphttpHdr
->
lpszField
=
WININET
_strdup
(
field
);
if
(
dwModifier
&
HTTP_ADDHDR_FLAG_REQ
)
lphttpHdr
->
wFlags
|=
HDR_ISREQUEST
;
...
...
@@ -2237,8 +2230,8 @@ BOOL HTTP_InsertCustomHeader(LPWININETHTTPREQA lpwhr, LPHTTPHEADERA lpHdr)
if
(
NULL
!=
lph
)
{
lpwhr
->
pCustHeaders
=
lph
;
lpwhr
->
pCustHeaders
[
count
-
1
].
lpszField
=
HTTP
_strdup
(
lpHdr
->
lpszField
);
lpwhr
->
pCustHeaders
[
count
-
1
].
lpszValue
=
HTTP
_strdup
(
lpHdr
->
lpszValue
);
lpwhr
->
pCustHeaders
[
count
-
1
].
lpszField
=
WININET
_strdup
(
lpHdr
->
lpszField
);
lpwhr
->
pCustHeaders
[
count
-
1
].
lpszValue
=
WININET
_strdup
(
lpHdr
->
lpszValue
);
lpwhr
->
pCustHeaders
[
count
-
1
].
wFlags
=
lpHdr
->
wFlags
;
lpwhr
->
pCustHeaders
[
count
-
1
].
wCount
=
lpHdr
->
wCount
;
lpwhr
->
nCustHeaders
++
;
...
...
dlls/wininet/internet.c
View file @
e0e31478
...
...
@@ -82,6 +82,8 @@ typedef struct
}
WITHREADERROR
,
*
LPWITHREADERROR
;
BOOL
WINAPI
INTERNET_FindNextFileA
(
HINTERNET
hFind
,
LPVOID
lpvFindData
);
HINTERNET
WINAPI
INTERNET_InternetOpenUrlA
(
HINTERNET
hInternet
,
LPCSTR
lpszUrl
,
LPCSTR
lpszHeaders
,
DWORD
dwHeadersLength
,
DWORD
dwFlags
,
DWORD
dwContext
);
VOID
INTERNET_ExecuteWork
();
DWORD
g_dwTlsErrIndex
=
TLS_OUT_OF_INDEXES
;
...
...
@@ -1996,14 +1998,14 @@ BOOL WINAPI InternetCheckConnectionW(LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRes
/**********************************************************
* I
nternetOpenUrlA (WININET.@
)
* I
NTERNET_InternetOpenUrlA (internal
)
*
* Opens an URL
*
* RETURNS
* handle of connection or NULL on failure
*/
HINTERNET
WINAPI
InternetOpenUrlA
(
HINTERNET
hInternet
,
LPCSTR
lpszUrl
,
HINTERNET
WINAPI
I
NTERNET_I
nternetOpenUrlA
(
HINTERNET
hInternet
,
LPCSTR
lpszUrl
,
LPCSTR
lpszHeaders
,
DWORD
dwHeadersLength
,
DWORD
dwFlags
,
DWORD
dwContext
)
{
URL_COMPONENTSA
urlComponents
;
...
...
@@ -2035,10 +2037,11 @@ HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
urlComponents
.
nPort
=
INTERNET_DEFAULT_FTP_PORT
;
client
=
InternetConnectA
(
hInternet
,
hostName
,
urlComponents
.
nPort
,
userName
,
password
,
INTERNET_SERVICE_FTP
,
dwFlags
,
dwContext
);
return
FtpOpenFileA
(
client
,
path
,
GENERIC_READ
,
dwFlags
,
dwContext
);
client1
=
FtpOpenFileA
(
client
,
path
,
GENERIC_READ
,
dwFlags
,
dwContext
);
break
;
case
INTERNET_SCHEME_HTTP
:
case
INTERNET_SCHEME_HTTPS
:
{
case
INTERNET_SCHEME_HTTPS
:
{
LPCSTR
accept
[
2
]
=
{
"*/*"
,
NULL
};
if
(
urlComponents
.
nPort
==
0
)
{
if
(
urlComponents
.
nScheme
==
INTERNET_SCHEME_HTTP
)
...
...
@@ -2049,28 +2052,88 @@ HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
client
=
InternetConnectA
(
hInternet
,
hostName
,
urlComponents
.
nPort
,
userName
,
password
,
INTERNET_SERVICE_HTTP
,
dwFlags
,
dwContext
);
if
(
client
==
NULL
)
return
NULL
;
break
;
client1
=
HttpOpenRequestA
(
client
,
NULL
,
path
,
NULL
,
NULL
,
accept
,
dwFlags
,
dwContext
);
if
(
client1
==
NULL
)
{
InternetCloseHandle
(
client
);
return
NULL
;
break
;
}
HttpAddRequestHeadersA
(
client1
,
lpszHeaders
,
dwHeadersLength
,
HTTP_ADDREQ_FLAG_ADD
);
if
((
!
HttpSendRequestA
(
client1
,
NULL
,
0
,
NULL
,
0
))
&&
(
GetLastError
()
!=
ERROR_IO_PENDING
))
{
if
(
!
HTTP_HttpSendRequestA
(
client1
,
NULL
,
0
,
NULL
,
0
))
{
InternetCloseHandle
(
client1
);
InternetCloseHandle
(
client
);
return
NULL
;
client1
=
NULL
;
break
;
}
return
client1
;
}
case
INTERNET_SCHEME_GOPHER
:
/* gopher doesn't seem to be implemented in wine, but it's supposed
* to be supported by InternetOpenUrlA. */
default:
return
NULL
;
break
;
}
TRACE
(
" %p <--
\n
"
,
client1
);
return
client1
;
}
/**********************************************************
* InternetOpenUrlA (WININET.@)
*
* Opens an URL
*
* RETURNS
* handle of connection or NULL on failure
*/
HINTERNET
WINAPI
InternetOpenUrlA
(
HINTERNET
hInternet
,
LPCSTR
lpszUrl
,
LPCSTR
lpszHeaders
,
DWORD
dwHeadersLength
,
DWORD
dwFlags
,
DWORD
dwContext
)
{
HINTERNET
ret
=
NULL
;
LPWININETAPPINFOA
hIC
=
NULL
;
TRACE
(
"(%p, %s, %s, %08lx, %08lx, %08lx
\n
"
,
hInternet
,
debugstr_a
(
lpszUrl
),
debugstr_a
(
lpszHeaders
),
dwHeadersLength
,
dwFlags
,
dwContext
);
hIC
=
(
LPWININETAPPINFOA
)
WININET_GetObject
(
hInternet
);
if
(
NULL
==
hIC
||
hIC
->
hdr
.
htype
!=
WH_HINIT
)
{
INTERNET_SetLastError
(
ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
goto
lend
;
}
if
(
hIC
->
hdr
.
dwFlags
&
INTERNET_FLAG_ASYNC
)
{
WORKREQUEST
workRequest
;
struct
WORKREQ_INTERNETOPENURLA
*
req
;
workRequest
.
asyncall
=
INTERNETOPENURLA
;
workRequest
.
handle
=
hInternet
;
req
=
&
workRequest
.
u
.
InternetOpenUrlA
;
if
(
lpszUrl
)
req
->
lpszUrl
=
WININET_strdup
(
lpszUrl
);
else
req
->
lpszUrl
=
0
;
if
(
lpszHeaders
)
req
->
lpszHeaders
=
WININET_strdup
(
lpszHeaders
);
else
req
->
lpszHeaders
=
0
;
req
->
dwHeadersLength
=
dwHeadersLength
;
req
->
dwFlags
=
dwFlags
;
req
->
dwContext
=
dwContext
;
INTERNET_AsyncCall
(
&
workRequest
);
/*
* This is from windows.
*/
SetLastError
(
ERROR_IO_PENDING
);
}
else
{
ret
=
INTERNET_InternetOpenUrlA
(
hInternet
,
lpszUrl
,
lpszHeaders
,
dwHeadersLength
,
dwFlags
,
dwContext
);
}
lend:
TRACE
(
" %p <--
\n
"
,
ret
);
return
ret
;
}
/**********************************************************
* InternetOpenUrlW (WININET.@)
...
...
@@ -2470,6 +2533,17 @@ VOID INTERNET_ExecuteWork()
req
->
dwStatusInfoLength
);
}
break
;
case
INTERNETOPENURLA
:
{
struct
WORKREQ_INTERNETOPENURLA
*
req
=
&
workRequest
.
u
.
InternetOpenUrlA
;
INTERNET_InternetOpenUrlA
(
workRequest
.
handle
,
req
->
lpszUrl
,
req
->
lpszHeaders
,
req
->
dwHeadersLength
,
req
->
dwFlags
,
req
->
dwContext
);
HeapFree
(
GetProcessHeap
(),
0
,
req
->
lpszUrl
);
HeapFree
(
GetProcessHeap
(),
0
,
req
->
lpszHeaders
);
}
break
;
}
}
...
...
dlls/wininet/internet.h
View file @
e0e31478
...
...
@@ -54,6 +54,13 @@ typedef struct
#endif
}
WININET_NETCONNECTION
;
inline
static
LPSTR
WININET_strdup
(
LPCSTR
str
)
{
LPSTR
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
str
)
+
1
);
if
(
ret
)
strcpy
(
ret
,
str
);
return
ret
;
}
typedef
enum
{
WH_HINIT
=
INTERNET_HANDLE_TYPE_INTERNET
,
...
...
@@ -181,6 +188,7 @@ typedef enum
HTTPSENDREQUESTA
,
HTTPOPENREQUESTA
,
SENDCALLBACK
,
INTERNETOPENURLA
,
}
ASYNC_FUNC
;
struct
WORKREQ_FTPPUTFILEA
...
...
@@ -282,6 +290,16 @@ struct WORKREQ_SENDCALLBACK
DWORD
dwStatusInfoLength
;
};
struct
WORKREQ_INTERNETOPENURLA
{
HINTERNET
hInternet
;
LPSTR
lpszUrl
;
LPSTR
lpszHeaders
;
DWORD
dwHeadersLength
;
DWORD
dwFlags
;
DWORD
dwContext
;
};
typedef
struct
WORKREQ
{
ASYNC_FUNC
asyncall
;
...
...
@@ -302,6 +320,7 @@ typedef struct WORKREQ
struct
WORKREQ_HTTPOPENREQUESTA
HttpOpenRequestA
;
struct
WORKREQ_HTTPSENDREQUESTA
HttpSendRequestA
;
struct
WORKREQ_SENDCALLBACK
SendCallback
;
struct
WORKREQ_INTERNETOPENURLA
InternetOpenUrlA
;
}
u
;
struct
WORKREQ
*
next
;
...
...
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