Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: net/quic/spdy_utils.h

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/reliable_quic_stream_test.cc ('k') | net/quic/spdy_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_QUIC_SPDY_UTILS_H_
6 #define NET_QUIC_SPDY_UTILS_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <map>
12 #include <string>
13
14 #include "base/macros.h"
15 #include "net/base/net_export.h"
16 #include "net/quic/quic_header_list.h"
17 #include "net/quic/quic_protocol.h"
18 #include "net/spdy/spdy_framer.h"
19
20 namespace net {
21
22 class NET_EXPORT_PRIVATE SpdyUtils {
23 public:
24 static std::string SerializeUncompressedHeaders(
25 const SpdyHeaderBlock& headers);
26
27 // Parses |data| as a std::string containing serialized HTTP/2 HEADERS frame,
28 // populating |headers| with the key->value std:pairs found.
29 // |content_length| will be populated with the value of the content-length
30 // header if one or more are present.
31 // Returns true on success, false if parsing fails, or invalid keys are found.
32 static bool ParseHeaders(const char* data,
33 uint32_t data_len,
34 int64_t* content_length,
35 SpdyHeaderBlock* headers);
36
37 // Parses |data| as a std::string containing serialized HTTP/2 HEADERS frame,
38 // populating |trailers| with the key->value std:pairs found.
39 // The final offset header will be excluded from |trailers|, and instead the
40 // value will be copied to |final_byte_offset|.
41 // Returns true on success, false if parsing fails, or invalid keys are found.
42 static bool ParseTrailers(const char* data,
43 uint32_t data_len,
44 size_t* final_byte_offset,
45 SpdyHeaderBlock* trailers);
46
47 // Copies a list of headers to a SpdyHeaderBlock. Performs similar validation
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.
55 static bool CopyAndValidateTrailers(const QuicHeaderList& header_list,
56 size_t* final_byte_offset,
57 SpdyHeaderBlock* trailers);
58
59 // Returns URL composed from scheme, authority, and path header
60 // values, or empty string if any of those fields are missing.
61 static std::string GetUrlFromHeaderBlock(const net::SpdyHeaderBlock& headers);
62
63 // Returns hostname, or empty std::string if missing.
64 static std::string GetHostNameFromHeaderBlock(const SpdyHeaderBlock& headers);
65
66 // Returns true if result of |GetUrlFromHeaderBlock()| is non-empty
67 // and is a well-formed URL.
68 static bool UrlIsValid(const net::SpdyHeaderBlock& headers);
69
70 private:
71 DISALLOW_COPY_AND_ASSIGN(SpdyUtils);
72 };
73
74 } // namespace net
75
76 #endif // NET_QUIC_SPDY_UTILS_H_
OLDNEW
« no previous file with comments | « net/quic/reliable_quic_stream_test.cc ('k') | net/quic/spdy_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698