Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Unified Diff: net/http/http_stream_parser.cc

Issue 6134003: Prototype of chunked transfer encoded POST. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/http/http_stream_parser.cc
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 2a3fb156d585a72561361b961458c7657b5501d9..e6a290c8f26e84233c87eb72ee2be49b75e9f755 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -11,6 +11,7 @@
#include "net/base/ssl_cert_request_info.h"
#include "net/http/http_net_log_params.h"
#include "net/http/http_request_headers.h"
+#include "net/base/load_flags.h"
wtc 2011/01/14 03:09:31 Nit: remove this header.
Satish 2011/01/14 18:09:29 Done.
#include "net/http/http_request_info.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
@@ -67,6 +68,8 @@ int HttpStreamParser::SendRequest(const std::string& request_line,
request_headers_ = new DrainableIOBuffer(headers_io_buf,
headers_io_buf->size());
request_body_.reset(request_body);
+ if (request_body)
wtc 2011/01/14 03:09:31 Nit: request_body => request_body_
Satish 2011/01/14 18:09:29 Done.
+ request_body_->set_chunk_callback(this);
vandebo (ex-Chrome) 2011/01/14 05:53:44 set_chunk_callback will be called even when not us
Satish 2011/01/14 18:09:29 Changed now to only set for chunked streams
io_state_ = STATE_SENDING_HEADERS;
int result = DoLoop(OK);
@@ -143,6 +146,10 @@ void HttpStreamParser::OnIOComplete(int result) {
}
}
+void HttpStreamParser::OnChunkAvailable() {
+ OnIOComplete(0);
wtc 2011/01/14 03:09:31 IMPORTANT: this should do nothing unless we're in
vandebo (ex-Chrome) 2011/01/14 05:53:44 Indeed, this mustn't do anything unless io_state =
Satish 2011/01/14 18:09:29 Done.
Satish 2011/01/14 18:09:29 Done.
+}
+
int HttpStreamParser::DoLoop(int result) {
bool can_do_more = true;
do {
@@ -236,7 +243,8 @@ int HttpStreamParser::DoSendHeaders(int result) {
result = connection_->socket()->Write(request_headers_,
bytes_remaining,
&io_callback_);
- } else if (request_body_ != NULL && request_body_->size()) {
+ } else if (request_body_ != NULL &&
+ (request_body_->is_chunked() || request_body_->size())) {
io_state_ = STATE_SENDING_BODY;
result = OK;
} else {
@@ -251,8 +259,13 @@ int HttpStreamParser::DoSendBody(int result) {
if (!request_body_->eof()) {
int buf_len = static_cast<int>(request_body_->buf_len());
- result = connection_->socket()->Write(request_body_->buf(), buf_len,
- &io_callback_);
+ if (buf_len) {
+ result = connection_->socket()->Write(request_body_->buf(), buf_len,
+ &io_callback_);
+ } else {
+ // More POST data is to come hence wait for the callback.
+ result = ERR_IO_PENDING;
+ }
} else {
io_state_ = STATE_REQUEST_SENT;
}

Powered by Google App Engine
This is Rietveld 408576698