HttpRequest: follow 302 redirects by default.
This commit is contained in:
@@ -40,7 +40,8 @@ BHttpRequest::BHttpRequest(const BUrl& url, BUrlResult& result, bool ssl,
|
|||||||
fRequestStatus(kRequestInitialState),
|
fRequestStatus(kRequestInitialState),
|
||||||
fOptHeaders(NULL),
|
fOptHeaders(NULL),
|
||||||
fOptInputData(NULL),
|
fOptInputData(NULL),
|
||||||
fOptInputDataSize(-1)
|
fOptInputDataSize(-1),
|
||||||
|
fOptFollowLocation(true)
|
||||||
{
|
{
|
||||||
_ResetOptions();
|
_ResetOptions();
|
||||||
if (ssl)
|
if (ssl)
|
||||||
@@ -299,12 +300,7 @@ BHttpRequest::_ProtocolLoop()
|
|||||||
if (fResult.StatusCode() == B_HTTP_STATUS_MOVED_PERMANENTLY) {
|
if (fResult.StatusCode() == B_HTTP_STATUS_MOVED_PERMANENTLY) {
|
||||||
BString locationUrl = fHeaders["Location"];
|
BString locationUrl = fHeaders["Location"];
|
||||||
|
|
||||||
// Absolute path
|
fUrl.Redirect(locationUrl);
|
||||||
if (locationUrl[0] == '/')
|
|
||||||
fUrl.SetPath(locationUrl);
|
|
||||||
// URI
|
|
||||||
else
|
|
||||||
fUrl.SetUrlString(locationUrl);
|
|
||||||
|
|
||||||
if (--maxRedirs > 0) {
|
if (--maxRedirs > 0) {
|
||||||
newRequest = true;
|
newRequest = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user