• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors
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_SPDY_HEADER_COALESCER_H_
6 #define NET_SPDY_HEADER_COALESCER_H_
7 
8 #include "base/strings/string_piece.h"
9 #include "net/base/net_export.h"
10 #include "net/log/net_log_with_source.h"
11 #include "net/third_party/quiche/src/quiche/spdy/core/http2_header_block.h"
12 #include "net/third_party/quiche/src/quiche/spdy/core/spdy_headers_handler_interface.h"
13 
14 namespace net {
15 
16 class NET_EXPORT_PRIVATE HeaderCoalescer
17     : public spdy::SpdyHeadersHandlerInterface {
18  public:
19   HeaderCoalescer(uint32_t max_header_list_size,
20                   const NetLogWithSource& net_log);
21 
OnHeaderBlockStart()22   void OnHeaderBlockStart() override {}
23 
24   void OnHeader(absl::string_view key, absl::string_view value) override;
25 
OnHeaderBlockEnd(size_t uncompressed_header_bytes,size_t compressed_header_bytes)26   void OnHeaderBlockEnd(size_t uncompressed_header_bytes,
27                         size_t compressed_header_bytes) override {}
28 
29   spdy::Http2HeaderBlock release_headers();
error_seen()30   bool error_seen() const { return error_seen_; }
31 
32  private:
33   // Helper to add a header. Return true on success.
34   bool AddHeader(base::StringPiece key, base::StringPiece value);
35 
36   spdy::Http2HeaderBlock headers_;
37   bool headers_valid_ = true;
38   size_t header_list_size_ = 0;
39   bool error_seen_ = false;
40   bool regular_header_seen_ = false;
41   const uint32_t max_header_list_size_;
42   NetLogWithSource net_log_;
43 };
44 
45 }  // namespace net
46 
47 #endif  // NET_SPDY_HEADER_COALESCER_H_
48