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

Unified Diff: net/tools/quic/quic_spdy_client_stream.cc

Issue 1501493003: Pull HTTP/2 header parsing into utility method, from QuicSpdy{Client,Server}Streams. Not used in pr… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@108651883
Patch Set: Created 5 years 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/tools/quic/quic_spdy_client_stream.h ('k') | net/tools/quic/quic_spdy_server_stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_spdy_client_stream.cc
diff --git a/net/tools/quic/quic_spdy_client_stream.cc b/net/tools/quic/quic_spdy_client_stream.cc
index 817366c7a03d1c4c8af8e9da0b474fce5e38553a..48554b5a44f6768b789811a12442a0020504adca 100644
--- a/net/tools/quic/quic_spdy_client_stream.cc
+++ b/net/tools/quic/quic_spdy_client_stream.cc
@@ -44,11 +44,24 @@ void QuicSpdyClientStream::OnStreamHeadersComplete(bool fin,
size_t frame_len) {
header_bytes_read_ = frame_len;
QuicSpdyStream::OnStreamHeadersComplete(fin, frame_len);
- if (!ParseResponseHeaders(decompressed_headers().data(),
- decompressed_headers().length())) {
+ if (!SpdyUtils::ParseHeaders(decompressed_headers().data(),
+ decompressed_headers().length(),
+ &content_length_, &response_headers_)) {
Reset(QUIC_BAD_APPLICATION_PAYLOAD);
return;
}
+
+ string status = response_headers_[":status"].as_string();
+ size_t end = status.find(" ");
+ if (end != string::npos) {
+ status.erase(end);
+ }
+ if (!StringToInt(status, &response_code_)) {
+ // Invalid response code.
+ Reset(QUIC_BAD_APPLICATION_PAYLOAD);
+ return;
+ }
+
MarkHeadersConsumed(decompressed_headers().length());
}
@@ -77,31 +90,6 @@ void QuicSpdyClientStream::OnDataAvailable() {
}
}
-bool QuicSpdyClientStream::ParseResponseHeaders(const char* data,
- uint32 data_len) {
- DCHECK(headers_decompressed());
- SpdyFramer framer(HTTP2);
- if (!framer.ParseHeaderBlockInBuffer(data, data_len, &response_headers_) ||
- response_headers_.empty()) {
- return false; // Headers were invalid.
- }
-
- if (ContainsKey(response_headers_, "content-length") &&
- !StringToInt(StringPiece(response_headers_["content-length"]),
- &content_length_)) {
- return false; // Invalid content-length.
- }
- string status = response_headers_[":status"].as_string();
- size_t end = status.find(" ");
- if (end != string::npos) {
- status.erase(end);
- }
- if (!StringToInt(status, &response_code_)) {
- return false; // Invalid response code.
- }
- return true;
-}
-
size_t QuicSpdyClientStream::SendRequest(const SpdyHeaderBlock& headers,
StringPiece body,
bool fin) {
« no previous file with comments | « net/tools/quic/quic_spdy_client_stream.h ('k') | net/tools/quic/quic_spdy_server_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698