| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/tools/quic/quic_spdy_server_stream.h" | 5 #include "net/tools/quic/quic_spdy_server_stream.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | |
| 8 #include "net/quic/quic_session.h" | 7 #include "net/quic/quic_session.h" |
| 9 #include "net/spdy/spdy_framer.h" | 8 #include "net/spdy/spdy_framer.h" |
| 10 #include "net/tools/quic/quic_in_memory_cache.h" | 9 #include "net/tools/quic/quic_in_memory_cache.h" |
| 11 #include "net/tools/quic/spdy_utils.h" | 10 #include "net/tools/quic/spdy_utils.h" |
| 12 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 13 | 12 |
| 14 using base::StringPiece; | 13 using base::StringPiece; |
| 15 using std::string; | 14 using std::string; |
| 16 | 15 |
| 17 namespace net { | 16 namespace net { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 DVLOG(1) << "Special response: ignoring request."; | 114 DVLOG(1) << "Special response: ignoring request."; |
| 116 return; | 115 return; |
| 117 } | 116 } |
| 118 | 117 |
| 119 DVLOG(1) << "Sending response for stream " << id(); | 118 DVLOG(1) << "Sending response for stream " << id(); |
| 120 SendHeadersAndBody(response->headers(), response->body()); | 119 SendHeadersAndBody(response->headers(), response->body()); |
| 121 } | 120 } |
| 122 | 121 |
| 123 void QuicSpdyServerStream::SendErrorResponse() { | 122 void QuicSpdyServerStream::SendErrorResponse() { |
| 124 DVLOG(1) << "Sending error response for stream " << id(); | 123 DVLOG(1) << "Sending error response for stream " << id(); |
| 125 BalsaHeaders headers; | 124 SpdyHeaderBlock headers; |
| 126 headers.SetResponseFirstlineFromStringPieces( | 125 headers[":version"] = "HTTP/1.1"; |
| 127 "HTTP/1.1", "500", "Server Error"); | 126 headers[":status"] = "500 Server Error"; |
| 128 headers.ReplaceOrAppendHeader("content-length", "3"); | 127 headers["content-length"] = "3"; |
| 129 SendHeadersAndBody(headers, "bad"); | 128 SendHeadersAndBody(headers, "bad"); |
| 130 } | 129 } |
| 131 | 130 |
| 132 void QuicSpdyServerStream::SendHeadersAndBody( | 131 void QuicSpdyServerStream::SendHeadersAndBody( |
| 133 const BalsaHeaders& response_headers, | 132 const SpdyHeaderBlock& response_headers, |
| 134 StringPiece body) { | 133 StringPiece body) { |
| 135 // We only support SPDY and HTTP, and neither handles bidirectional streaming. | 134 // We only support SPDY and HTTP, and neither handles bidirectional streaming. |
| 136 if (!read_side_closed()) { | 135 if (!read_side_closed()) { |
| 137 CloseReadSide(); | 136 CloseReadSide(); |
| 138 } | 137 } |
| 139 | 138 |
| 140 SpdyHeaderBlock header_block = | 139 WriteHeaders(response_headers, body.empty(), nullptr); |
| 141 SpdyUtils::ResponseHeadersToSpdyHeaders(response_headers); | |
| 142 | |
| 143 WriteHeaders(header_block, body.empty(), nullptr); | |
| 144 | 140 |
| 145 if (!body.empty()) { | 141 if (!body.empty()) { |
| 146 WriteOrBufferData(body, true, nullptr); | 142 WriteOrBufferData(body, true, nullptr); |
| 147 } | 143 } |
| 148 } | 144 } |
| 149 | 145 |
| 150 } // namespace tools | 146 } // namespace tools |
| 151 } // namespace net | 147 } // namespace net |
| OLD | NEW |