Skip port number before calling gethostbyname.

Fix non-absolute urls.
This commit is contained in:
Nikolas Zimmermann 2001-10-04 18:12:41 +00:00 committed by Alexandre Julliard
parent f26d2522af
commit 76598823d0
2 changed files with 29 additions and 1 deletions

View File

@ -605,6 +605,15 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
if (NULL == lpwhr->lpszPath)
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 */
requestStringLen =
strlen(lpwhr->lpszVerb) +

View File

@ -113,9 +113,28 @@ time_t ConvertTimeString(LPCSTR asctime)
BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
struct hostent **phe, struct sockaddr_in *psa)
{
char *found;
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)
{
TRACE("Failed to get hostname: (%s)\n", lpszServerName);