| 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 // This file contains some protocol structures for use with SPDY 2 and 3 | 5 // This file contains some protocol structures for use with SPDY 2 and 3 |
| 6 // The SPDY 2 spec can be found at: | 6 // The SPDY 2 spec can be found at: |
| 7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft2 | 7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft2 |
| 8 // The SPDY 3 spec can be found at: | 8 // The SPDY 3 spec can be found at: |
| 9 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 | 9 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 // Initial window size for a Spdy stream in bytes. | 49 // Initial window size for a Spdy stream in bytes. |
| 50 const int32 kSpdyStreamInitialWindowSize = 64 * 1024; // 64 KBytes | 50 const int32 kSpdyStreamInitialWindowSize = 64 * 1024; // 64 KBytes |
| 51 | 51 |
| 52 // Initial window size for a Spdy session in bytes. | 52 // Initial window size for a Spdy session in bytes. |
| 53 const int32 kSpdySessionInitialWindowSize = 64 * 1024; // 64 KBytes | 53 const int32 kSpdySessionInitialWindowSize = 64 * 1024; // 64 KBytes |
| 54 | 54 |
| 55 // Maximum window size for a Spdy stream or session. | 55 // Maximum window size for a Spdy stream or session. |
| 56 const int32 kSpdyMaximumWindowSize = 0x7FFFFFFF; // Max signed 32bit int | 56 const int32 kSpdyMaximumWindowSize = 0x7FFFFFFF; // Max signed 32bit int |
| 57 | 57 |
| 58 // Maximum padding size in octets for one DATA or HEADERS or PUSH_PROMISE frame. |
| 59 const int32 kPaddingSizePerFrame = 256; |
| 60 |
| 58 // SPDY 2 dictionary. | 61 // SPDY 2 dictionary. |
| 59 // This is just a hacked dictionary to use for shrinking HTTP-like headers. | 62 // This is just a hacked dictionary to use for shrinking HTTP-like headers. |
| 60 const char kV2Dictionary[] = | 63 const char kV2Dictionary[] = |
| 61 "optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-" | 64 "optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-" |
| 62 "languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi" | 65 "languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi" |
| 63 "f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser" | 66 "f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser" |
| 64 "-agent10010120020120220320420520630030130230330430530630740040140240340440" | 67 "-agent10010120020120220320420520630030130230330430530630740040140240340440" |
| 65 "5406407408409410411412413414415416417500501502503504505accept-rangesageeta" | 68 "5406407408409410411412413414415416417500501502503504505accept-rangesageeta" |
| 66 "glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic" | 69 "glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic" |
| 67 "ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran" | 70 "ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 CONTINUATION, | 290 CONTINUATION, |
| 288 ALTSVC, | 291 ALTSVC, |
| 289 PRIORITY | 292 PRIORITY |
| 290 }; | 293 }; |
| 291 | 294 |
| 292 // Flags on data packets. | 295 // Flags on data packets. |
| 293 enum SpdyDataFlags { | 296 enum SpdyDataFlags { |
| 294 DATA_FLAG_NONE = 0x00, | 297 DATA_FLAG_NONE = 0x00, |
| 295 DATA_FLAG_FIN = 0x01, | 298 DATA_FLAG_FIN = 0x01, |
| 296 DATA_FLAG_END_SEGMENT = 0x02, | 299 DATA_FLAG_END_SEGMENT = 0x02, |
| 297 DATA_FLAG_PAD_LOW = 0x08, | 300 DATA_FLAG_PADDED = 0x08, |
| 298 DATA_FLAG_PAD_HIGH = 0x10, | |
| 299 DATA_FLAG_COMPRESSED = 0x20, | 301 DATA_FLAG_COMPRESSED = 0x20, |
| 300 }; | 302 }; |
| 301 | 303 |
| 302 // Flags on control packets | 304 // Flags on control packets |
| 303 enum SpdyControlFlags { | 305 enum SpdyControlFlags { |
| 304 CONTROL_FLAG_NONE = 0x00, | 306 CONTROL_FLAG_NONE = 0x00, |
| 305 CONTROL_FLAG_FIN = 0x01, | 307 CONTROL_FLAG_FIN = 0x01, |
| 306 CONTROL_FLAG_UNIDIRECTIONAL = 0x02, | 308 CONTROL_FLAG_UNIDIRECTIONAL = 0x02, |
| 307 }; | 309 }; |
| 308 | 310 |
| 309 enum SpdyPingFlags { | 311 enum SpdyPingFlags { |
| 310 PING_FLAG_ACK = 0x01, | 312 PING_FLAG_ACK = 0x01, |
| 311 }; | 313 }; |
| 312 | 314 |
| 313 // Used by HEADERS, PUSH_PROMISE, and CONTINUATION. | 315 // Used by HEADERS, PUSH_PROMISE, and CONTINUATION. |
| 314 enum SpdyHeadersFlags { | 316 enum SpdyHeadersFlags { |
| 315 HEADERS_FLAG_END_SEGMENT = 0x02, | 317 HEADERS_FLAG_END_SEGMENT = 0x02, |
| 316 HEADERS_FLAG_END_HEADERS = 0x04, | 318 HEADERS_FLAG_END_HEADERS = 0x04, |
| 317 HEADERS_FLAG_PAD_LOW = 0x08, | 319 HEADERS_FLAG_PADDED = 0x08, |
| 318 HEADERS_FLAG_PAD_HIGH = 0x10, | |
| 319 HEADERS_FLAG_PRIORITY = 0x20, | 320 HEADERS_FLAG_PRIORITY = 0x20, |
| 320 }; | 321 }; |
| 321 | 322 |
| 322 enum SpdyPushPromiseFlags { | 323 enum SpdyPushPromiseFlags { |
| 323 PUSH_PROMISE_FLAG_END_PUSH_PROMISE = 0x04, | 324 PUSH_PROMISE_FLAG_END_PUSH_PROMISE = 0x04, |
| 325 PUSH_PROMISE_FLAG_PADDED = 0x08, |
| 324 }; | 326 }; |
| 325 | 327 |
| 326 // Flags on the SETTINGS control frame. | 328 // Flags on the SETTINGS control frame. |
| 327 enum SpdySettingsControlFlags { | 329 enum SpdySettingsControlFlags { |
| 328 SETTINGS_FLAG_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS = 0x01, | 330 SETTINGS_FLAG_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS = 0x01, |
| 329 }; | 331 }; |
| 330 | 332 |
| 331 enum Http2SettingsControlFlags { | 333 enum Http2SettingsControlFlags { |
| 332 SETTINGS_FLAG_ACK = 0x01, | 334 SETTINGS_FLAG_ACK = 0x01, |
| 333 }; | 335 }; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 // Performs deep copy on data. | 616 // Performs deep copy on data. |
| 615 SpdyDataIR(SpdyStreamId stream_id, const base::StringPiece& data); | 617 SpdyDataIR(SpdyStreamId stream_id, const base::StringPiece& data); |
| 616 | 618 |
| 617 // Use in conjunction with SetDataShallow() for shallow-copy on data. | 619 // Use in conjunction with SetDataShallow() for shallow-copy on data. |
| 618 explicit SpdyDataIR(SpdyStreamId stream_id); | 620 explicit SpdyDataIR(SpdyStreamId stream_id); |
| 619 | 621 |
| 620 virtual ~SpdyDataIR(); | 622 virtual ~SpdyDataIR(); |
| 621 | 623 |
| 622 base::StringPiece data() const { return data_; } | 624 base::StringPiece data() const { return data_; } |
| 623 | 625 |
| 624 bool pad_low() const { return pad_low_; } | 626 bool padded() const { return padded_; } |
| 625 | |
| 626 bool pad_high() const { return pad_high_; } | |
| 627 | 627 |
| 628 int padding_payload_len() const { return padding_payload_len_; } | 628 int padding_payload_len() const { return padding_payload_len_; } |
| 629 | 629 |
| 630 void set_padding_len(int padding_len) { | 630 void set_padding_len(int padding_len) { |
| 631 // The padding_len should be in (0, 65535 + 2]. | |
| 632 // Note that SpdyFramer::GetDataFrameMaximumPayload() enforces the overall | |
| 633 // payload size later so we actually can't pad more than 16375 bytes. | |
| 634 DCHECK_GT(padding_len, 0); | 631 DCHECK_GT(padding_len, 0); |
| 635 DCHECK_LT(padding_len, 65537); | 632 DCHECK_LE(padding_len, kPaddingSizePerFrame); |
| 636 | 633 padded_ = true; |
| 637 if (padding_len <= 256) { | 634 // The pad field takes one octet on the wire. |
| 638 pad_low_ = true; | 635 padding_payload_len_ = padding_len - 1; |
| 639 --padding_len; | |
| 640 } else { | |
| 641 pad_low_ = pad_high_ = true; | |
| 642 padding_len -= 2; | |
| 643 } | |
| 644 padding_payload_len_ = padding_len; | |
| 645 } | 636 } |
| 646 | 637 |
| 647 // Deep-copy of data (keep private copy). | 638 // Deep-copy of data (keep private copy). |
| 648 void SetDataDeep(const base::StringPiece& data) { | 639 void SetDataDeep(const base::StringPiece& data) { |
| 649 data_store_.reset(new std::string(data.data(), data.length())); | 640 data_store_.reset(new std::string(data.data(), data.length())); |
| 650 data_ = *(data_store_.get()); | 641 data_ = *(data_store_.get()); |
| 651 } | 642 } |
| 652 | 643 |
| 653 // Shallow-copy of data (do not keep private copy). | 644 // Shallow-copy of data (do not keep private copy). |
| 654 void SetDataShallow(const base::StringPiece& data) { | 645 void SetDataShallow(const base::StringPiece& data) { |
| 655 data_store_.reset(); | 646 data_store_.reset(); |
| 656 data_ = data; | 647 data_ = data; |
| 657 } | 648 } |
| 658 | 649 |
| 659 virtual void Visit(SpdyFrameVisitor* visitor) const OVERRIDE; | 650 virtual void Visit(SpdyFrameVisitor* visitor) const OVERRIDE; |
| 660 | 651 |
| 661 private: | 652 private: |
| 662 // Used to store data that this SpdyDataIR should own. | 653 // Used to store data that this SpdyDataIR should own. |
| 663 scoped_ptr<std::string> data_store_; | 654 scoped_ptr<std::string> data_store_; |
| 664 base::StringPiece data_; | 655 base::StringPiece data_; |
| 665 | 656 |
| 666 bool pad_low_; | 657 bool padded_; |
| 667 bool pad_high_; | |
| 668 // padding_payload_len_ = desired padding length - len(padding length field). | 658 // padding_payload_len_ = desired padding length - len(padding length field). |
| 669 int padding_payload_len_; | 659 int padding_payload_len_; |
| 670 | 660 |
| 671 DISALLOW_COPY_AND_ASSIGN(SpdyDataIR); | 661 DISALLOW_COPY_AND_ASSIGN(SpdyDataIR); |
| 672 }; | 662 }; |
| 673 | 663 |
| 674 class NET_EXPORT_PRIVATE SpdySynStreamIR | 664 class NET_EXPORT_PRIVATE SpdySynStreamIR |
| 675 : public SpdyFrameWithNameValueBlockIR { | 665 : public SpdyFrameWithNameValueBlockIR { |
| 676 public: | 666 public: |
| 677 explicit SpdySynStreamIR(SpdyStreamId stream_id) | 667 explicit SpdySynStreamIR(SpdyStreamId stream_id) |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 SpdyFrameVisitor() {} | 1041 SpdyFrameVisitor() {} |
| 1052 virtual ~SpdyFrameVisitor() {} | 1042 virtual ~SpdyFrameVisitor() {} |
| 1053 | 1043 |
| 1054 private: | 1044 private: |
| 1055 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); | 1045 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); |
| 1056 }; | 1046 }; |
| 1057 | 1047 |
| 1058 } // namespace net | 1048 } // namespace net |
| 1059 | 1049 |
| 1060 #endif // NET_SPDY_SPDY_PROTOCOL_H_ | 1050 #endif // NET_SPDY_SPDY_PROTOCOL_H_ |
| OLD | NEW |