diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-11 18:28:08 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-11 18:28:08 +0000 |
commit | 476e8c9a3bf203b6b0612020cecc52dad353f027 (patch) | |
tree | 5b503d15a10cb467333458b3767c215ffabd78a7 /chrome_frame/npapi_url_request.cc | |
parent | fce4086e59228437577c4ef30f0c8cab49f245af (diff) | |
download | chromium_src-476e8c9a3bf203b6b0612020cecc52dad353f027.zip chromium_src-476e8c9a3bf203b6b0612020cecc52dad353f027.tar.gz chromium_src-476e8c9a3bf203b6b0612020cecc52dad353f027.tar.bz2 |
Submitting issue 1613010 for Eric.
Original change: http://codereview.chromium.org/1613010
Description: Fixed extra headers and message passing for post requests in NPAPIUrlRequest.
TEST=none
BUG=none
TBR=robertshield
Review URL: http://codereview.chromium.org/1549032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44210 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/npapi_url_request.cc')
-rw-r--r-- | chrome_frame/npapi_url_request.cc | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/chrome_frame/npapi_url_request.cc b/chrome_frame/npapi_url_request.cc index 5306fb9..235caf5 100644 --- a/chrome_frame/npapi_url_request.cc +++ b/chrome_frame/npapi_url_request.cc @@ -1,31 +1,6 @@ -// Copyright 2010, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Copyright (c) 2010 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. #include "chrome_frame/npapi_url_request.h" @@ -88,8 +63,30 @@ bool NPAPIUrlRequest::Start() { // it using XHR result = npapi::GetURLNotify(instance_, url().c_str(), NULL, this); } else if (LowerCaseEqualsASCII(method(), "post")) { + uint32 data_len = static_cast<uint32>(post_data_len()); + + std::string buffer; + if (extra_headers().length() > 0) { + buffer += extra_headers(); + TrimWhitespace(buffer, TRIM_ALL, &buffer); + + // Firefox looks specifically for "Content-length: \d+\r\n\r\n" + // to detect if extra headers are added to the message buffer. + buffer += "\r\nContent-length: "; + buffer += IntToString(data_len); + buffer += "\r\n\r\n"; + } + + std::string data; + data.resize(data_len); + uint32 bytes_read; + upload_data_->Read(&data[0], data_len, + reinterpret_cast<ULONG*>(&bytes_read)); + DCHECK_EQ(data_len, bytes_read); + buffer += data; + result = npapi::PostURLNotify(instance_, url().c_str(), NULL, - extra_headers().length(), extra_headers().c_str(), false, this); + buffer.length(), buffer.c_str(), false, this); } else { NOTREACHED() << "PluginUrlRequest only supports 'GET'/'POST'"; } |