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

Unified Diff: net/spdy/spdy_stream.cc

Issue 1272283003: Add a new SpdyStream::Delegate method to handle trailers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add NOTREACHED Created 5 years, 4 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
« no previous file with comments | « net/spdy/spdy_stream.h ('k') | net/spdy/spdy_stream_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_stream.cc
diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc
index a78a78f790f4bfda1fe43cbb2704fd4d118894b3..812d5205bb5d56ee7147711afd6a3c831e92f9ff 100644
--- a/net/spdy/spdy_stream.cc
+++ b/net/spdy/spdy_stream.cc
@@ -57,6 +57,8 @@ bool ContainsUppercaseAscii(const std::string& str) {
} // namespace
+void SpdyStream::Delegate::OnTrailers(const SpdyHeaderBlock& trailers) {}
+
// A wrapper around a stream that calls into ProduceSynStreamFrame().
class SpdyStream::SynStreamBufferProducer : public SpdyBufferProducer {
public:
@@ -440,12 +442,18 @@ int SpdyStream::OnInitialResponseHeadersReceived(
int SpdyStream::OnAdditionalResponseHeadersReceived(
const SpdyHeaderBlock& additional_response_headers) {
if (type_ == SPDY_REQUEST_RESPONSE_STREAM) {
- session_->ResetStream(
- stream_id_, RST_STREAM_PROTOCOL_ERROR,
- "Additional headers received for request/response stream");
- return ERR_SPDY_PROTOCOL_ERROR;
- } else if (type_ == SPDY_PUSH_STREAM &&
- response_headers_status_ == RESPONSE_HEADERS_ARE_COMPLETE) {
+ if (response_headers_status_ != RESPONSE_HEADERS_ARE_COMPLETE) {
+ session_->ResetStream(
+ stream_id_, RST_STREAM_PROTOCOL_ERROR,
+ "Additional headers received for request/response stream");
+ return ERR_SPDY_PROTOCOL_ERROR;
+ }
+ response_headers_status_ = TRAILERS_RECEIVED;
+ delegate_->OnTrailers(additional_response_headers);
+ return OK;
+ }
+ if (type_ == SPDY_PUSH_STREAM &&
+ response_headers_status_ == RESPONSE_HEADERS_ARE_COMPLETE) {
session_->ResetStream(
stream_id_, RST_STREAM_PROTOCOL_ERROR,
"Additional headers received for push stream");
@@ -484,6 +492,14 @@ void SpdyStream::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) {
return;
}
+ if (response_headers_status_ == TRAILERS_RECEIVED && buffer) {
+ // TRAILERS_RECEIVED is only used in SPDY_REQUEST_RESPONSE_STREAM.
+ DCHECK_EQ(type_, SPDY_REQUEST_RESPONSE_STREAM);
+ session_->ResetStream(stream_id_, RST_STREAM_PROTOCOL_ERROR,
+ "Data received after trailers");
+ return;
+ }
+
// If we have response headers but the delegate has indicated that
// it's still incomplete, then that's a protocol error.
if (response_headers_status_ == RESPONSE_HEADERS_ARE_INCOMPLETE) {
« no previous file with comments | « net/spdy/spdy_stream.h ('k') | net/spdy/spdy_stream_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698