Skip port number before calling gethostbyname.
Fix non-absolute urls.
This commit is contained in:
parent
f26d2522af
commit
76598823d0
|
@ -605,6 +605,15 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
|
||||||
if (NULL == lpwhr->lpszPath)
|
if (NULL == lpwhr->lpszPath)
|
||||||
lpwhr->lpszPath = HTTP_strdup("/");
|
lpwhr->lpszPath = HTTP_strdup("/");
|
||||||
|
|
||||||
|
if(lpwhr->lpszPath[0] != '/') /* not an absolute path ?? --> fix it !! */
|
||||||
|
{
|
||||||
|
char *fixurl = HeapAlloc(GetProcessHeap(), 0, strlen(lpwhr->lpszPath) + 2);
|
||||||
|
*fixurl = '/';
|
||||||
|
strcpy(fixurl + 1, lpwhr->lpszPath);
|
||||||
|
HeapFree( GetProcessHeap(), 0, lpwhr->lpszPath );
|
||||||
|
lpwhr->lpszPath = fixurl;
|
||||||
|
}
|
||||||
|
|
||||||
/* Calculate length of request string */
|
/* Calculate length of request string */
|
||||||
requestStringLen =
|
requestStringLen =
|
||||||
strlen(lpwhr->lpszVerb) +
|
strlen(lpwhr->lpszVerb) +
|
||||||
|
|
|
@ -113,9 +113,28 @@ time_t ConvertTimeString(LPCSTR asctime)
|
||||||
BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
|
BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
|
||||||
struct hostent **phe, struct sockaddr_in *psa)
|
struct hostent **phe, struct sockaddr_in *psa)
|
||||||
{
|
{
|
||||||
|
char *found;
|
||||||
|
|
||||||
TRACE("%s\n", lpszServerName);
|
TRACE("%s\n", lpszServerName);
|
||||||
|
|
||||||
*phe = gethostbyname(lpszServerName);
|
/* Validate server name first
|
||||||
|
* Check if there is sth. like
|
||||||
|
* pinger.macromedia.com:80
|
||||||
|
* if yes, eliminate the :80....
|
||||||
|
*/
|
||||||
|
found = strchr(lpszServerName, ':');
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
int len = found - lpszServerName;
|
||||||
|
char *new = HeapAlloc(GetProcessHeap(), 0, len + 1);
|
||||||
|
memcpy( new, lpszServerName, len );
|
||||||
|
new[len] = '\0';
|
||||||
|
TRACE("Found a ':' inside the server name, reparsed name: %s\n", new);
|
||||||
|
*phe = gethostbyname(new);
|
||||||
|
HeapFree( GetProcessHeap(), 0, new );
|
||||||
|
}
|
||||||
|
else *phe = gethostbyname(lpszServerName);
|
||||||
|
|
||||||
if (NULL == *phe)
|
if (NULL == *phe)
|
||||||
{
|
{
|
||||||
TRACE("Failed to get hostname: (%s)\n", lpszServerName);
|
TRACE("Failed to get hostname: (%s)\n", lpszServerName);
|
||||||
|
|
Loading…
Reference in New Issue