summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-26 23:42:42 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-26 23:42:42 +0000
commit8f170168f091f5199ef91ee138b9b030a8a53817 (patch)
treeeff82afe27264a0cfccfee837a16442a77892f92 /chrome_frame
parent87e57e72ad7fefdcb4ee3e952ce27829018c0b66 (diff)
downloadchromium_src-8f170168f091f5199ef91ee138b9b030a8a53817.zip
chromium_src-8f170168f091f5199ef91ee138b9b030a8a53817.tar.gz
chromium_src-8f170168f091f5199ef91ee138b9b030a8a53817.tar.bz2
Add support for chunked encoding in ChromeFrame for POST requests. This fixes the
URLRequestTestHTTP.TestPostChunkedDataBeforeStart net test failure in ChromeFrame. To support chunked encoding we need to marshal the corresponding information in the net::UploadData object to ensure that this object gets reconstructed correctly on the other side (CF). Disabled the URLRequestTestHTTP.TestPostChunkedDataAfterStart for ChromeFrame as this test modifies the UploadData object after it has been marshaled over to CF which we don't support in ChromeFrame. BUG=none TEST=Covered by existing net tests. Review URL: http://codereview.chromium.org/6357017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72723 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/plugin_url_request.cc4
-rw-r--r--chrome_frame/plugin_url_request.h5
-rw-r--r--chrome_frame/test/net/fake_external_tab.cc3
-rw-r--r--chrome_frame/urlmon_upload_data_stream.cc7
-rw-r--r--chrome_frame/urlmon_url_request.cc16
5 files changed, 23 insertions, 12 deletions
diff --git a/chrome_frame/plugin_url_request.cc b/chrome_frame/plugin_url_request.cc
index 236090b..e0166bc 100644
--- a/chrome_frame/plugin_url_request.cc
+++ b/chrome_frame/plugin_url_request.cc
@@ -13,7 +13,8 @@ PluginUrlRequest::PluginUrlRequest()
post_data_len_(0),
enable_frame_busting_(false),
resource_type_(ResourceType::MAIN_FRAME),
- load_flags_(0) {
+ load_flags_(0),
+ is_chunked_upload_(false) {
}
PluginUrlRequest::~PluginUrlRequest() {
@@ -47,6 +48,7 @@ bool PluginUrlRequest::Initialize(PluginUrlRequestDelegate* delegate,
upload_stream->AddRef();
upload_stream->Initialize(upload_data);
upload_data_.Attach(upload_stream);
+ is_chunked_upload_ = upload_data->is_chunked();
}
}
diff --git a/chrome_frame/plugin_url_request.h b/chrome_frame/plugin_url_request.h
index cc9a17a..83325c9 100644
--- a/chrome_frame/plugin_url_request.h
+++ b/chrome_frame/plugin_url_request.h
@@ -149,6 +149,10 @@ class PluginUrlRequest {
return post_data_len_;
}
+ bool is_chunked_upload() const {
+ return is_chunked_upload_;
+ }
+
protected:
HRESULT get_upload_data(IStream** ret) {
DCHECK(ret);
@@ -181,6 +185,7 @@ class PluginUrlRequest {
ResourceType::Type resource_type_;
int load_flags_;
ScopedComPtr<IStream> upload_data_;
+ bool is_chunked_upload_;
};
#endif // CHROME_FRAME_PLUGIN_URL_REQUEST_H_
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc
index de87f08..5b69f3a 100644
--- a/chrome_frame/test/net/fake_external_tab.cc
+++ b/chrome_frame/test/net/fake_external_tab.cc
@@ -461,6 +461,9 @@ void FilterDisabledTests() {
// This test is disabled as it expects an empty UA to be echoed back from
// the server which is not the case in ChromeFrame.
"URLRequestTestHTTP.DefaultUserAgent",
+ // This test modifies the UploadData object after it has been marshaled to
+ // ChromeFrame. We don't support this.
+ "URLRequestTestHTTP.TestPostChunkedDataAfterStart",
};
std::string filter("-"); // All following filters will be negative.
diff --git a/chrome_frame/urlmon_upload_data_stream.cc b/chrome_frame/urlmon_upload_data_stream.cc
index 8b2a101..5664fbf 100644
--- a/chrome_frame/urlmon_upload_data_stream.cc
+++ b/chrome_frame/urlmon_upload_data_stream.cc
@@ -20,7 +20,7 @@ STDMETHODIMP UrlmonUploadDataStream::Read(void* pv, ULONG cb, ULONG* read) {
}
// Have we already read past the end of the stream?
- if (request_body_stream_->position() >= request_body_stream_->size()) {
+ if (request_body_stream_->eof()) {
if (read) {
*read = 0;
}
@@ -28,8 +28,7 @@ STDMETHODIMP UrlmonUploadDataStream::Read(void* pv, ULONG cb, ULONG* read) {
}
uint64 total_bytes_to_copy = std::min(static_cast<uint64>(cb),
- request_body_stream_->size() - request_body_stream_->position());
- uint64 initial_position = request_body_stream_->position();
+ static_cast<uint64>(request_body_stream_->buf_len()));
uint64 bytes_copied = 0;
@@ -55,8 +54,6 @@ STDMETHODIMP UrlmonUploadDataStream::Read(void* pv, ULONG cb, ULONG* read) {
}
DCHECK(bytes_copied == total_bytes_to_copy);
- DCHECK(request_body_stream_->position() ==
- initial_position + total_bytes_to_copy);
if (read) {
*read = static_cast<ULONG>(total_bytes_to_copy);
diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc
index acbb8a0..1a71f65 100644
--- a/chrome_frame/urlmon_url_request.cc
+++ b/chrome_frame/urlmon_url_request.cc
@@ -22,8 +22,8 @@
#include "chrome_frame/urlmon_upload_data_stream.h"
#include "chrome_frame/utils.h"
#include "net/base/load_flags.h"
-#include "net/http/http_util.h"
#include "net/http/http_response_headers.h"
+#include "net/http/http_util.h"
UrlmonUrlRequest::UrlmonUrlRequest()
: pending_read_size_(0),
@@ -567,11 +567,15 @@ STDMETHODIMP UrlmonUrlRequest::BeginningTransaction(const wchar_t* url,
std::string new_headers;
if (post_data_len() > 0) {
- // Tack on the Content-Length header since when using an IStream type
- // STGMEDIUM, it looks like it doesn't get set for us :(
- new_headers = base::StringPrintf(
- "Content-Length: %s\r\n",
- base::Int64ToString(post_data_len()).c_str());
+ if (is_chunked_upload()) {
+ new_headers = base::StringPrintf("Transfer-Encoding: chunked\r\n");
+ } else {
+ // Tack on the Content-Length header since when using an IStream type
+ // STGMEDIUM, it looks like it doesn't get set for us :(
+ new_headers = base::StringPrintf(
+ "Content-Length: %s\r\n",
+ base::Int64ToString(post_data_len()).c_str());
+ }
}
if (!extra_headers().empty()) {