| 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_client_stream.h" | 5 #include "net/tools/quic/quic_spdy_client_stream.h" |
| 6 | 6 |
| 7 #include "net/spdy/spdy_framer.h" | 7 #include "net/spdy/spdy_framer.h" |
| 8 #include "net/tools/quic/quic_client_session.h" | 8 #include "net/tools/quic/quic_client_session.h" |
| 9 #include "net/tools/quic/spdy_utils.h" | 9 #include "net/tools/quic/spdy_utils.h" |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 Reset(QUIC_BAD_APPLICATION_PAYLOAD); | 63 Reset(QUIC_BAD_APPLICATION_PAYLOAD); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 ssize_t QuicSpdyClientStream::SendRequest(const BalsaHeaders& headers, | 67 ssize_t QuicSpdyClientStream::SendRequest(const BalsaHeaders& headers, |
| 68 StringPiece body, | 68 StringPiece body, |
| 69 bool fin) { | 69 bool fin) { |
| 70 SpdyHeaderBlock header_block = | 70 SpdyHeaderBlock header_block = |
| 71 SpdyUtils::RequestHeadersToSpdyHeaders(headers); | 71 SpdyUtils::RequestHeadersToSpdyHeaders(headers); |
| 72 | 72 |
| 73 bool send_fin_with_headers = fin && body.empty(); |
| 73 string headers_string = session()->compressor()->CompressHeadersWithPriority( | 74 string headers_string = session()->compressor()->CompressHeadersWithPriority( |
| 74 priority(), header_block); | 75 priority(), header_block); |
| 76 WriteOrBufferData(headers_string, send_fin_with_headers); |
| 75 | 77 |
| 76 bool has_body = !body.empty(); | 78 if (!body.empty()) { |
| 77 | |
| 78 WriteOrBufferData(headers_string, fin && !has_body); // last_data | |
| 79 | |
| 80 if (has_body) { | |
| 81 WriteOrBufferData(body, fin); | 79 WriteOrBufferData(body, fin); |
| 82 } | 80 } |
| 83 | 81 |
| 84 return headers_string.size() + body.size(); | 82 return headers_string.size() + body.size(); |
| 85 } | 83 } |
| 86 | 84 |
| 87 int QuicSpdyClientStream::ParseResponseHeaders() { | 85 int QuicSpdyClientStream::ParseResponseHeaders() { |
| 88 size_t read_buf_len = static_cast<size_t>(read_buf_->offset()); | 86 size_t read_buf_len = static_cast<size_t>(read_buf_->offset()); |
| 89 SpdyFramer framer(SPDY3); | 87 SpdyFramer framer(SPDY3); |
| 90 SpdyHeaderBlock headers; | 88 SpdyHeaderBlock headers; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 109 return len; | 107 return len; |
| 110 } | 108 } |
| 111 | 109 |
| 112 // Sends body data to the server and returns the number of bytes sent. | 110 // Sends body data to the server and returns the number of bytes sent. |
| 113 void QuicSpdyClientStream::SendBody(const string& data, bool fin) { | 111 void QuicSpdyClientStream::SendBody(const string& data, bool fin) { |
| 114 return WriteOrBufferData(data, fin); | 112 return WriteOrBufferData(data, fin); |
| 115 } | 113 } |
| 116 | 114 |
| 117 } // namespace tools | 115 } // namespace tools |
| 118 } // namespace net | 116 } // namespace net |
| OLD | NEW |