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> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 // populating |trailers| with the key->value std:pairs found. | 38 // populating |trailers| with the key->value std:pairs found. |
39 // The final offset header will be excluded from |trailers|, and instead the | 39 // The final offset header will be excluded from |trailers|, and instead the |
40 // value will be copied to |final_byte_offset|. | 40 // value will be copied to |final_byte_offset|. |
41 // Returns true on success, false if parsing fails, or invalid keys are found. | 41 // Returns true on success, false if parsing fails, or invalid keys are found. |
42 static bool ParseTrailers(const char* data, | 42 static bool ParseTrailers(const char* data, |
43 uint32_t data_len, | 43 uint32_t data_len, |
44 size_t* final_byte_offset, | 44 size_t* final_byte_offset, |
45 SpdyHeaderBlock* trailers); | 45 SpdyHeaderBlock* trailers); |
46 | 46 |
47 // Copies a list of headers to a SpdyHeaderBlock. Performs similar validation | 47 // Copies a list of headers to a SpdyHeaderBlock. Performs similar validation |
48 // to SpdyFramer::ParseHeaderBlockInBuffer. | 48 // to SpdyFramer::ParseHeaderBlockInBuffer and ParseHeaders, above. |
| 49 static bool CopyAndValidateHeaders(const QuicHeaderList& header_list, |
| 50 int64_t* content_length, |
| 51 SpdyHeaderBlock* headers); |
| 52 |
| 53 // Copies a list of headers to a SpdyHeaderBlock. Performs similar validation |
| 54 // to SpdyFramer::ParseHeaderBlockInBuffer and ParseTrailers, above. |
49 static bool CopyAndValidateTrailers(const QuicHeaderList& header_list, | 55 static bool CopyAndValidateTrailers(const QuicHeaderList& header_list, |
50 size_t* final_byte_offset, | 56 size_t* final_byte_offset, |
51 SpdyHeaderBlock* trailers); | 57 SpdyHeaderBlock* trailers); |
52 | 58 |
53 // Returns URL composed from scheme, authority, and path header | 59 // Returns URL composed from scheme, authority, and path header |
54 // values, or empty string if any of those fields are missing. | 60 // values, or empty string if any of those fields are missing. |
55 static std::string GetUrlFromHeaderBlock(const net::SpdyHeaderBlock& headers); | 61 static std::string GetUrlFromHeaderBlock(const net::SpdyHeaderBlock& headers); |
56 | 62 |
57 // Returns hostname, or empty std::string if missing. | 63 // Returns hostname, or empty std::string if missing. |
58 static std::string GetHostNameFromHeaderBlock(const SpdyHeaderBlock& headers); | 64 static std::string GetHostNameFromHeaderBlock(const SpdyHeaderBlock& headers); |
59 | 65 |
60 // Returns true if result of |GetUrlFromHeaderBlock()| is non-empty | 66 // Returns true if result of |GetUrlFromHeaderBlock()| is non-empty |
61 // and is a well-formed URL. | 67 // and is a well-formed URL. |
62 static bool UrlIsValid(const net::SpdyHeaderBlock& headers); | 68 static bool UrlIsValid(const net::SpdyHeaderBlock& headers); |
63 | 69 |
64 private: | 70 private: |
65 DISALLOW_COPY_AND_ASSIGN(SpdyUtils); | 71 DISALLOW_COPY_AND_ASSIGN(SpdyUtils); |
66 }; | 72 }; |
67 | 73 |
68 } // namespace net | 74 } // namespace net |
69 | 75 |
70 #endif // NET_QUIC_SPDY_UTILS_H_ | 76 #endif // NET_QUIC_SPDY_UTILS_H_ |
OLD | NEW |