OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef NET_QUIC_SPDY_UTILS_H_ | 5 #ifndef NET_QUIC_SPDY_UTILS_H_ |
6 #define NET_QUIC_SPDY_UTILS_H_ | 6 #define NET_QUIC_SPDY_UTILS_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <map> | 11 #include <map> |
9 #include <string> | 12 #include <string> |
10 | 13 |
| 14 #include "base/macros.h" |
11 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
12 #include "net/quic/quic_protocol.h" | 16 #include "net/quic/quic_protocol.h" |
13 #include "net/spdy/spdy_framer.h" | 17 #include "net/spdy/spdy_framer.h" |
14 | 18 |
15 namespace net { | 19 namespace net { |
16 | 20 |
17 class NET_EXPORT_PRIVATE SpdyUtils { | 21 class NET_EXPORT_PRIVATE SpdyUtils { |
18 public: | 22 public: |
19 static std::string SerializeUncompressedHeaders( | 23 static std::string SerializeUncompressedHeaders( |
20 const SpdyHeaderBlock& headers); | 24 const SpdyHeaderBlock& headers); |
21 | 25 |
22 // Parses |data| as a std::string containing serialized HTTP/2 HEADERS frame, | 26 // Parses |data| as a std::string containing serialized HTTP/2 HEADERS frame, |
23 // populating |headers| with the key->value std:pairs found. | 27 // populating |headers| with the key->value std:pairs found. |
24 // |content_length| will be populated with the value of the content-length | 28 // |content_length| will be populated with the value of the content-length |
25 // header if one or more are present. | 29 // header if one or more are present. |
26 // Returns true on success, false if parsing fails, or invalid keys are found. | 30 // Returns true on success, false if parsing fails, or invalid keys are found. |
27 static bool ParseHeaders(const char* data, | 31 static bool ParseHeaders(const char* data, |
28 uint32 data_len, | 32 uint32_t data_len, |
29 int* content_length, | 33 int* content_length, |
30 SpdyHeaderBlock* headers); | 34 SpdyHeaderBlock* headers); |
31 | 35 |
32 // Parses |data| as a std::string containing serialized HTTP/2 HEADERS frame, | 36 // Parses |data| as a std::string containing serialized HTTP/2 HEADERS frame, |
33 // populating |trailers| with the key->value std:pairs found. | 37 // populating |trailers| with the key->value std:pairs found. |
34 // The final offset header will be excluded from |trailers|, and instead the | 38 // The final offset header will be excluded from |trailers|, and instead the |
35 // value will be copied to |final_byte_offset|. | 39 // value will be copied to |final_byte_offset|. |
36 // Returns true on success, false if parsing fails, or invalid keys are found. | 40 // Returns true on success, false if parsing fails, or invalid keys are found. |
37 static bool ParseTrailers(const char* data, | 41 static bool ParseTrailers(const char* data, |
38 uint32 data_len, | 42 uint32_t data_len, |
39 size_t* final_byte_offset, | 43 size_t* final_byte_offset, |
40 SpdyHeaderBlock* trailers); | 44 SpdyHeaderBlock* trailers); |
41 | 45 |
42 private: | 46 private: |
43 DISALLOW_COPY_AND_ASSIGN(SpdyUtils); | 47 DISALLOW_COPY_AND_ASSIGN(SpdyUtils); |
44 }; | 48 }; |
45 | 49 |
46 } // namespace net | 50 } // namespace net |
47 | 51 |
48 #endif // NET_QUIC_SPDY_UTILS_H_ | 52 #endif // NET_QUIC_SPDY_UTILS_H_ |
OLD | NEW |