bool NetworkJob::handleRedirect() { ASSERT(m_handle); if (!m_handle) return false; String location = m_response.httpHeaderField("Location"); if (location.isNull()) return false; KURL newURL(m_response.url(), location); if (!newURL.isValid()) return false; ResourceRequest newRequest = m_handle->firstRequest(); newRequest.setURL(newURL); newRequest.setMustHandleInternally(true); String method = newRequest.httpMethod().upper(); if (method != "GET" && method != "HEAD") { newRequest.setHTTPMethod("GET"); newRequest.setHTTPBody(0); newRequest.clearHTTPContentLength(); newRequest.clearHTTPContentType(); } // Do not send existing credentials with the new request. m_handle->getInternal()->m_currentWebChallenge.nullify(); return startNewJobWithRequest(newRequest, true); }
bool NetworkJob::handleRedirect() { ASSERT(m_handle); if (!m_handle || m_redirectCount >= s_redirectMaximum) return false; String location = m_response.httpHeaderField("Location"); if (location.isNull()) return false; KURL newURL(m_response.url(), location); if (!newURL.isValid()) return false; if (newURL.protocolIsData()) { m_extendedStatusCode = BlackBerry::Platform::FilterStream::StatusInvalidRedirectToData; return false; } ResourceRequest newRequest = m_handle->firstRequest(); newRequest.setURL(newURL); newRequest.setMustHandleInternally(true); String method = newRequest.httpMethod().upper(); if (method != "GET" && method != "HEAD") { newRequest.setHTTPMethod("GET"); newRequest.setHTTPBody(0); newRequest.clearHTTPContentLength(); newRequest.clearHTTPContentType(); } if (!m_handle->getInternal()->m_currentWebChallenge.isNull()) { // If this request is challenged, store the credentials now because the credential is correct (otherwise, it won't get here). storeCredentials(); // Do not send existing credentials with the new request. m_handle->getInternal()->m_currentWebChallenge.nullify(); } return startNewJobWithRequest(newRequest, true); }