| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 string headers_string = session()->compressor()->CompressHeadersWithPriority( | 73 string headers_string = session()->compressor()->CompressHeadersWithPriority( |
| 74 priority(), header_block); | 74 priority(), header_block); |
| 75 | 75 |
| 76 bool has_body = !body.empty(); | 76 bool has_body = !body.empty(); |
| 77 | 77 |
| 78 WriteData(headers_string, fin && !has_body); // last_data | 78 WriteOrBufferData(headers_string, fin && !has_body); // last_data |
| 79 | 79 |
| 80 if (has_body) { | 80 if (has_body) { |
| 81 WriteData(body, fin); | 81 WriteOrBufferData(body, fin); |
| 82 } | 82 } |
| 83 | 83 |
| 84 return headers_string.size() + body.size(); | 84 return headers_string.size() + body.size(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 int QuicSpdyClientStream::ParseResponseHeaders() { | 87 int QuicSpdyClientStream::ParseResponseHeaders() { |
| 88 size_t read_buf_len = static_cast<size_t>(read_buf_->offset()); | 88 size_t read_buf_len = static_cast<size_t>(read_buf_->offset()); |
| 89 SpdyFramer framer(SPDY3); | 89 SpdyFramer framer(SPDY3); |
| 90 SpdyHeaderBlock headers; | 90 SpdyHeaderBlock headers; |
| 91 char* data = read_buf_->StartOfBuffer(); | 91 char* data = read_buf_->StartOfBuffer(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 103 | 103 |
| 104 size_t delta = read_buf_len - len; | 104 size_t delta = read_buf_len - len; |
| 105 if (delta > 0) { | 105 if (delta > 0) { |
| 106 data_.append(data + len, delta); | 106 data_.append(data + len, delta); |
| 107 } | 107 } |
| 108 | 108 |
| 109 return len; | 109 return len; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Sends body data to the server and returns the number of bytes sent. | 112 // Sends body data to the server and returns the number of bytes sent. |
| 113 ssize_t QuicSpdyClientStream::SendBody(const string& data, bool fin) { | 113 void QuicSpdyClientStream::SendBody(const string& data, bool fin) { |
| 114 return WriteData(data, fin).bytes_consumed; | 114 return WriteOrBufferData(data, fin); |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace tools | 117 } // namespace tools |
| 118 } // namespace net | 118 } // namespace net |
| OLD | NEW |