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 |
11 #ifndef NET_SPDY_SPDY_PROTOCOL_H_ | 11 #ifndef NET_SPDY_SPDY_PROTOCOL_H_ |
12 #define NET_SPDY_SPDY_PROTOCOL_H_ | 12 #define NET_SPDY_SPDY_PROTOCOL_H_ |
13 | 13 |
14 #include <limits> | 14 #include <limits> |
15 #include <map> | 15 #include <map> |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
19 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
20 #include "base/logging.h" | 20 #include "base/logging.h" |
21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
22 #include "base/strings/string_piece.h" | 22 #include "base/strings/string_piece.h" |
23 #include "base/sys_byteorder.h" | 23 #include "base/sys_byteorder.h" |
24 #include "net/base/net_export.h" | 24 #include "net/base/net_export.h" |
25 #include "net/spdy/spdy_alt_svc_wire_format.h" | 25 #include "net/spdy/spdy_alt_svc_wire_format.h" |
26 #include "net/spdy/spdy_bitmasks.h" | 26 #include "net/spdy/spdy_bitmasks.h" |
| 27 #include "net/spdy/spdy_header_block.h" |
27 | 28 |
28 namespace net { | 29 namespace net { |
29 | 30 |
30 // The major versions of SPDY. Major version differences indicate | 31 // The major versions of SPDY. Major version differences indicate |
31 // framer-layer incompatibility, as opposed to minor version numbers | 32 // framer-layer incompatibility, as opposed to minor version numbers |
32 // which indicate application-layer incompatibility. Do not rely on | 33 // which indicate application-layer incompatibility. Do not rely on |
33 // the mapping from enum value SPDYn to the integer n. | 34 // the mapping from enum value SPDYn to the integer n. |
34 enum SpdyMajorVersion { | 35 enum SpdyMajorVersion { |
35 SPDY2 = 2, | 36 SPDY2 = 2, |
36 SPDY_MIN_VERSION = SPDY2, | 37 SPDY_MIN_VERSION = SPDY2, |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 GOAWAY_ENHANCE_YOUR_CALM = 11, | 414 GOAWAY_ENHANCE_YOUR_CALM = 11, |
414 GOAWAY_INADEQUATE_SECURITY = 12, | 415 GOAWAY_INADEQUATE_SECURITY = 12, |
415 GOAWAY_HTTP_1_1_REQUIRED = 13 | 416 GOAWAY_HTTP_1_1_REQUIRED = 13 |
416 }; | 417 }; |
417 | 418 |
418 // A SPDY priority is a number between 0 and 7 (inclusive). | 419 // A SPDY priority is a number between 0 and 7 (inclusive). |
419 // SPDY priority range is version-dependent. For SPDY 2 and below, priority is a | 420 // SPDY priority range is version-dependent. For SPDY 2 and below, priority is a |
420 // number between 0 and 3. | 421 // number between 0 and 3. |
421 typedef uint8 SpdyPriority; | 422 typedef uint8 SpdyPriority; |
422 | 423 |
423 // A datastructure for holding a set of headers from a HEADERS, PUSH_PROMISE, | |
424 // SYN_STREAM, or SYN_REPLY frame. | |
425 typedef std::map<std::string, std::string> SpdyHeaderBlock; | |
426 | |
427 typedef uint64 SpdyPingId; | 424 typedef uint64 SpdyPingId; |
428 | 425 |
429 typedef std::string SpdyProtocolId; | 426 typedef std::string SpdyProtocolId; |
430 | 427 |
431 enum class SpdyHeaderValidatorType { | 428 enum class SpdyHeaderValidatorType { |
432 REQUEST, | 429 REQUEST, |
433 RESPONSE_HEADER, | 430 RESPONSE_HEADER, |
434 RESPONSE_TRAILER | 431 RESPONSE_TRAILER |
435 }; | 432 }; |
436 | 433 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 // block. Implies SpdyFrameWithFinIR. | 608 // block. Implies SpdyFrameWithFinIR. |
612 class NET_EXPORT_PRIVATE SpdyFrameWithHeaderBlockIR | 609 class NET_EXPORT_PRIVATE SpdyFrameWithHeaderBlockIR |
613 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { | 610 : public NON_EXPORTED_BASE(SpdyFrameWithFinIR) { |
614 public: | 611 public: |
615 const SpdyHeaderBlock& header_block() const { return header_block_; } | 612 const SpdyHeaderBlock& header_block() const { return header_block_; } |
616 void set_header_block(const SpdyHeaderBlock& header_block) { | 613 void set_header_block(const SpdyHeaderBlock& header_block) { |
617 // Deep copy. | 614 // Deep copy. |
618 header_block_ = header_block; | 615 header_block_ = header_block; |
619 } | 616 } |
620 void SetHeader(base::StringPiece name, base::StringPiece value) { | 617 void SetHeader(base::StringPiece name, base::StringPiece value) { |
621 header_block_[name.as_string()] = value.as_string(); | 618 header_block_[name] = value; |
622 } | 619 } |
623 SpdyHeaderBlock* mutable_header_block() { return &header_block_; } | 620 SpdyHeaderBlock* mutable_header_block() { return &header_block_; } |
624 | 621 |
625 protected: | 622 protected: |
626 explicit SpdyFrameWithHeaderBlockIR(SpdyStreamId stream_id); | 623 explicit SpdyFrameWithHeaderBlockIR(SpdyStreamId stream_id); |
627 ~SpdyFrameWithHeaderBlockIR() override; | 624 ~SpdyFrameWithHeaderBlockIR() override; |
628 | 625 |
629 private: | 626 private: |
630 SpdyHeaderBlock header_block_; | 627 SpdyHeaderBlock header_block_; |
631 | 628 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 SpdyFrameVisitor() {} | 1078 SpdyFrameVisitor() {} |
1082 virtual ~SpdyFrameVisitor() {} | 1079 virtual ~SpdyFrameVisitor() {} |
1083 | 1080 |
1084 private: | 1081 private: |
1085 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); | 1082 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); |
1086 }; | 1083 }; |
1087 | 1084 |
1088 } // namespace net | 1085 } // namespace net |
1089 | 1086 |
1090 #endif // NET_SPDY_SPDY_PROTOCOL_H_ | 1087 #endif // NET_SPDY_SPDY_PROTOCOL_H_ |
OLD | NEW |