OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // HttpRequestHeaders manages the request headers. | 5 // HttpRequestHeaders manages the request headers. |
6 // It maintains these in a vector of header key/value pairs, thereby maintaining | 6 // It maintains these in a vector of header key/value pairs, thereby maintaining |
7 // the order of the headers. This means that any lookups are linear time | 7 // the order of the headers. This means that any lookups are linear time |
8 // operations. | 8 // operations. |
9 | 9 |
10 #ifndef NET_HTTP_HTTP_REQUEST_HEADERS_H_ | 10 #ifndef NET_HTTP_HTTP_REQUEST_HEADERS_H_ |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 bool GetHeader(const base::StringPiece& key, std::string* out) const; | 88 bool GetHeader(const base::StringPiece& key, std::string* out) const; |
89 | 89 |
90 // Clears all the headers. | 90 // Clears all the headers. |
91 void Clear(); | 91 void Clear(); |
92 | 92 |
93 // Sets the header value pair for |key| and |value|. If |key| already exists, | 93 // Sets the header value pair for |key| and |value|. If |key| already exists, |
94 // then the header value is modified, but the key is untouched, and the order | 94 // then the header value is modified, but the key is untouched, and the order |
95 // in the vector remains the same. When comparing |key|, case is ignored. | 95 // in the vector remains the same. When comparing |key|, case is ignored. |
96 void SetHeader(const base::StringPiece& key, const base::StringPiece& value); | 96 void SetHeader(const base::StringPiece& key, const base::StringPiece& value); |
97 | 97 |
| 98 // Sets the header value pair for |key| and |value|, if |key| does not exist. |
| 99 // If |key| already exists, the call is a no-op. |
| 100 // When comparing |key|, case is ignored. |
| 101 void SetHeaderIfMissing(const base::StringPiece& key, |
| 102 const base::StringPiece& value); |
| 103 |
98 // Removes the first header that matches (case insensitive) |key|. | 104 // Removes the first header that matches (case insensitive) |key|. |
99 void RemoveHeader(const base::StringPiece& key); | 105 void RemoveHeader(const base::StringPiece& key); |
100 | 106 |
101 // Parses the header from a string and calls SetHeader() with it. This string | 107 // Parses the header from a string and calls SetHeader() with it. This string |
102 // should not contain any CRLF. As per RFC2616, the format is: | 108 // should not contain any CRLF. As per RFC2616, the format is: |
103 // | 109 // |
104 // message-header = field-name ":" [ field-value ] | 110 // message-header = field-name ":" [ field-value ] |
105 // field-name = token | 111 // field-name = token |
106 // field-value = *( field-content | LWS ) | 112 // field-value = *( field-content | LWS ) |
107 // field-content = <the OCTETs making up the field-value | 113 // field-content = <the OCTETs making up the field-value |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // Allow the copy construction and operator= to facilitate copying in | 145 // Allow the copy construction and operator= to facilitate copying in |
140 // HttpRequestInfo. | 146 // HttpRequestInfo. |
141 // TODO(willchan): Investigate to see if we can remove the need to copy | 147 // TODO(willchan): Investigate to see if we can remove the need to copy |
142 // HttpRequestInfo. | 148 // HttpRequestInfo. |
143 // DISALLOW_COPY_AND_ASSIGN(HttpRequestHeaders); | 149 // DISALLOW_COPY_AND_ASSIGN(HttpRequestHeaders); |
144 }; | 150 }; |
145 | 151 |
146 } // namespace net | 152 } // namespace net |
147 | 153 |
148 #endif // NET_HTTP_HTTP_REQUEST_HEADERS_H_ | 154 #endif // NET_HTTP_HTTP_REQUEST_HEADERS_H_ |
OLD | NEW |