| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/quic/quic_spdy_server_stream.h" | 5 #include "net/quic/quic_spdy_server_stream.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "net/quic/quic_in_memory_cache.h" | 9 #include "net/quic/quic_in_memory_cache.h" |
| 10 #include "net/quic/quic_session.h" | 10 #include "net/quic/quic_session.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 DVLOG(1) << "Sending response for stream " << id(); | 131 DVLOG(1) << "Sending response for stream " << id(); |
| 132 SendHeadersAndBody(response->headers(), response->body()); | 132 SendHeadersAndBody(response->headers(), response->body()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void QuicSpdyServerStream::SendErrorResponse() { | 135 void QuicSpdyServerStream::SendErrorResponse() { |
| 136 DVLOG(1) << "Sending error response for stream " << id(); | 136 DVLOG(1) << "Sending error response for stream " << id(); |
| 137 scoped_refptr<HttpResponseHeaders> headers | 137 scoped_refptr<HttpResponseHeaders> headers |
| 138 = new HttpResponseHeaders(string("HTTP/1.1 500 Server Error") + '\0' + | 138 = new HttpResponseHeaders(string("HTTP/1.1 500 Server Error") + '\0' + |
| 139 "content-length: 3" + '\0' + '\0'); | 139 "content-length: 3" + '\0' + '\0'); |
| 140 SendHeadersAndBody(*headers, "bad"); | 140 SendHeadersAndBody(*headers.get(), "bad"); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void QuicSpdyServerStream::SendHeadersAndBody( | 143 void QuicSpdyServerStream::SendHeadersAndBody( |
| 144 const HttpResponseHeaders& response_headers, | 144 const HttpResponseHeaders& response_headers, |
| 145 StringPiece body) { | 145 StringPiece body) { |
| 146 // We only support SPDY and HTTP, and neither handles bidirectional streaming. | 146 // We only support SPDY and HTTP, and neither handles bidirectional streaming. |
| 147 if (!read_side_closed()) { | 147 if (!read_side_closed()) { |
| 148 CloseReadSide(); | 148 CloseReadSide(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 SpdyHeaderBlock header_block; | 151 SpdyHeaderBlock header_block; |
| 152 CreateSpdyHeadersFromHttpResponse(response_headers, | 152 CreateSpdyHeadersFromHttpResponse(response_headers, |
| 153 kDefaultSpdyMajorVersion, | 153 kDefaultSpdyMajorVersion, |
| 154 &header_block); | 154 &header_block); |
| 155 | 155 |
| 156 WriteHeaders(header_block, body.empty(), NULL); | 156 WriteHeaders(header_block, body.empty(), NULL); |
| 157 | 157 |
| 158 if (!body.empty()) { | 158 if (!body.empty()) { |
| 159 WriteOrBufferData(body, true, NULL); | 159 WriteOrBufferData(body, true, NULL); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace net | 163 } // namespace net |
| OLD | NEW |