[haiku-commits] Re: haiku: hrev50921 - in src/apps/haikudepot: server util

  • From: "Adrien Destugues" <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 31 Jan 2017 08:25:24 +0000

31 janvier 2017 08:47 apl@xxxxxxxxxxxxxx a écrit:

+ } else if (BHttpRequest::IsRedirectionStatusCode(statusCode)) {
+ const BHttpHeaders responseHeaders = result.Headers();
+ const char *locationValue = responseHeaders["Location"];
+
+ if (NULL != locationValue && 0 != strlen(locationValue)) {
+ BUrl location(locationValue);

The value of the location header can be a relative URL. In that case it is 
relative to the original request. So here you need to do this:

BUrl location(result.Url(), locationValue);

If the location is absolute, the base URL is ignored when doing this, so it 
works as expected.

+ fprintf(stdout, "will redirect to; %s\n",
+ location.UrlString().String());
return _Download(tarGzFilePath, location, redirects + 1, 0);
- }
-
- fprintf(stdout, "unable to find 'Location' header for redirect\n");
- return B_IO_ERROR;
}

-- 
Adrien.

Other related posts: