Windows should animate when they are about to get docked at screen edges.
[chromium-blink-merge.git] / net / tools / quic / quic_reliable_server_stream.cc
blob58b884a1082562566f921b3972a7d45e02084de1
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
3 // found in the LICENSE file.
5 #include "net/tools/quic/quic_reliable_server_stream.h"
7 #include "base/logging.h"
8 #include "base/memory/singleton.h"
9 #include "net/tools/quic/quic_in_memory_cache.h"
11 using base::StringPiece;
13 namespace net {
14 namespace tools {
16 QuicReliableServerStream::QuicReliableServerStream(QuicStreamId id,
17 QuicSession* session)
18 : ReliableQuicStream(id, session) {
22 void QuicReliableServerStream::SendResponse() {
23 // Find response in cache. If not found, send error response.
24 const QuicInMemoryCache::Response* response =
25 QuicInMemoryCache::GetInstance()->GetResponse(headers_);
26 if (response == NULL) {
27 SendErrorResponse();
28 return;
31 DLOG(INFO) << "Sending response for stream " << id();
32 SendHeaders(response->headers());
33 WriteData(response->body(), true);
36 void QuicReliableServerStream::SendErrorResponse() {
37 DLOG(INFO) << "Sending error response for stream " << id();
38 BalsaHeaders headers;
39 headers.SetResponseFirstlineFromStringPieces(
40 "HTTP/1.1", "500", "Server Error");
41 headers.ReplaceOrAppendHeader("content-length", "3");
42 SendHeaders(headers);
43 WriteData("bad", true);
46 QuicConsumedData QuicReliableServerStream::WriteData(StringPiece data,
47 bool fin) {
48 // We only support SPDY and HTTP, and neither handles bidirectional streaming.
49 if (!read_side_closed()) {
50 CloseReadSide();
52 return ReliableQuicStream::WriteData(data, fin);
55 } // namespace tools
56 } // namespace net