1 // Copyright (c) 2019 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 QUICHE_QUIC_CORE_QPACK_VALUE_SPLITTING_HEADER_LIST_H_ 6 #define QUICHE_QUIC_CORE_QPACK_VALUE_SPLITTING_HEADER_LIST_H_ 7 8 #include "absl/strings/string_view.h" 9 #include "quiche/quic/platform/api/quic_export.h" 10 #include "quiche/spdy/core/http2_header_block.h" 11 12 namespace quic { 13 14 // A wrapper class around Http2HeaderBlock that splits header values along ';' 15 // separators (while also removing optional space following separator) for 16 // cookies and along '\0' separators for other header fields. 17 class QUICHE_EXPORT ValueSplittingHeaderList { 18 public: 19 using value_type = spdy::Http2HeaderBlock::value_type; 20 21 class QUICHE_EXPORT const_iterator { 22 public: 23 // |header_list| must outlive this object. 24 const_iterator(const spdy::Http2HeaderBlock* header_list, 25 spdy::Http2HeaderBlock::const_iterator header_list_iterator); 26 const_iterator(const const_iterator&) = default; 27 const_iterator& operator=(const const_iterator&) = delete; 28 29 bool operator==(const const_iterator& other) const; 30 bool operator!=(const const_iterator& other) const; 31 32 const const_iterator& operator++(); 33 34 const value_type& operator*() const; 35 const value_type* operator->() const; 36 37 private: 38 // Find next separator; update |value_end_| and |header_field_|. 39 void UpdateHeaderField(); 40 41 const spdy::Http2HeaderBlock* const header_list_; 42 spdy::Http2HeaderBlock::const_iterator header_list_iterator_; 43 absl::string_view::size_type value_start_; 44 absl::string_view::size_type value_end_; 45 value_type header_field_; 46 }; 47 48 // |header_list| must outlive this object. 49 explicit ValueSplittingHeaderList(const spdy::Http2HeaderBlock* header_list); 50 ValueSplittingHeaderList(const ValueSplittingHeaderList&) = delete; 51 ValueSplittingHeaderList& operator=(const ValueSplittingHeaderList&) = delete; 52 53 const_iterator begin() const; 54 const_iterator end() const; 55 56 private: 57 const spdy::Http2HeaderBlock* const header_list_; 58 }; 59 60 } // namespace quic 61 62 #endif // QUICHE_QUIC_CORE_QPACK_VALUE_SPLITTING_HEADER_LIST_H_ 63