diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-06 19:58:07 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-06 19:58:07 +0000 |
commit | bd752e3661dc7311313888303794d59ffd817044 (patch) | |
tree | eabba395dfcae1d4a33e098e9d73cba98b7387d7 /chrome_frame | |
parent | c83f4335d3552a27a7f6fd2b37eff89182804663 (diff) | |
download | chromium_src-bd752e3661dc7311313888303794d59ffd817044.zip chromium_src-bd752e3661dc7311313888303794d59ffd817044.tar.gz chromium_src-bd752e3661dc7311313888303794d59ffd817044.tar.bz2 |
Empty XHR posts requests fail in ChromeFrame with status code 0. The POST requests makes it across to the
server which responds with a status code of 204 indicating no content. However the underlying urlmon layer
calls the OnStopBinding method on the bind status callback with the E_ABORT status code.
We should be reading the response codes off the binding.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=109335
BUG=109335
Review URL: http://codereview.chromium.org/9114022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116721 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/urlmon_url_request.cc | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc index dce42f8..e640694 100644 --- a/chrome_frame/urlmon_url_request.cc +++ b/chrome_frame/urlmon_url_request.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -28,6 +28,8 @@ #include "net/http/http_response_headers.h" #include "net/http/http_util.h" +#define IS_HTTP_SUCCESS_CODE(code) (code >= 200 && code <= 299) + UrlmonUrlRequest::UrlmonUrlRequest() : pending_read_size_(0), headers_received_(false), @@ -381,13 +383,25 @@ STDMETHODIMP UrlmonUrlRequest::OnStopBinding(HRESULT result, LPCWSTR error) { if (state == Status::WORKING) { status_.set_result(result); - // Special case. If the last request was a redirect and the current OS - // error value is E_ACCESSDENIED, that means an unsafe redirect was - // attempted. In that case, correct the OS error value to be the more - // specific ERR_UNSAFE_REDIRECT error value. - if (result == E_ACCESSDENIED) { + if (FAILED(result)) { int http_code = GetHttpResponseStatusFromBinding(binding_); - if (300 <= http_code && http_code < 400) { + // For certain requests like empty POST requests the server can return + // back a HTTP success code in the range 200 to 299. We need to flag + // these requests as succeeded. + if (IS_HTTP_SUCCESS_CODE(http_code)) { + // If this DCHECK fires it means that the server returned a HTTP + // success code outside the standard range 200-206. We need to confirm + // if the following code path is correct. + DCHECK_LE(http_code, 206); + status_.set_result(S_OK); + std::string headers = GetHttpHeadersFromBinding(binding_); + OnResponse(0, UTF8ToWide(headers).c_str(), NULL, NULL); + } else if (net::HttpResponseHeaders::IsRedirectResponseCode(http_code) && + result == E_ACCESSDENIED) { + // Special case. If the last request was a redirect and the current OS + // error value is E_ACCESSDENIED, that means an unsafe redirect was + // attempted. In that case, correct the OS error value to be the more + // specific ERR_UNSAFE_REDIRECT error value. status_.set_result(net::URLRequestStatus::FAILED, net::ERR_UNSAFE_REDIRECT); } |