Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_HTTP_HTTP_UTIL_H_ | 5 #ifndef NET_HTTP_HTTP_UTIL_H_ |
| 6 #define NET_HTTP_HTTP_UTIL_H_ | 6 #define NET_HTTP_HTTP_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 | 140 |
| 141 // Returns the start of the status line, or -1 if no status line was found. | 141 // Returns the start of the status line, or -1 if no status line was found. |
| 142 // This allows for 4 bytes of junk to precede the status line (which is what | 142 // This allows for 4 bytes of junk to precede the status line (which is what |
| 143 // mozilla does too). | 143 // mozilla does too). |
| 144 static int LocateStartOfStatusLine(const char* buf, int buf_len); | 144 static int LocateStartOfStatusLine(const char* buf, int buf_len); |
| 145 | 145 |
| 146 // Returns index beyond the end-of-headers marker or -1 if not found. RFC | 146 // Returns index beyond the end-of-headers marker or -1 if not found. RFC |
| 147 // 2616 defines the end-of-headers marker as a double CRLF; however, some | 147 // 2616 defines the end-of-headers marker as a double CRLF; however, some |
| 148 // servers only send back LFs (e.g., Unix-based CGI scripts written using the | 148 // servers only send back LFs (e.g., Unix-based CGI scripts written using the |
| 149 // ASIS Apache module). This function therefore accepts the pattern LF[CR]LF | 149 // ASIS Apache module). This function therefore accepts the pattern LF[CR]LF |
| 150 // as end-of-headers (just like Mozilla). | 150 // as end-of-headers (just like Mozilla). |
|
mmenke
2015/06/09 20:23:37
Maybe add: "The first line of |buf| is considered
haavardm
2015/06/10 11:54:01
Done.
| |
| 151 // The parameter |i| is the offset within |buf| to begin searching from. | 151 // The parameter |i| is the offset within |buf| to begin searching from. |
| 152 static int LocateEndOfHeaders(const char* buf, int buf_len, int i = 0); | 152 static int LocateEndOfHeaders(const char* buf, int buf_len, int i = 0); |
| 153 | 153 |
| 154 // Same as |LocateEndOfHeaders| with the difference that it detects | |
| 155 // an empty header list if |buf| starts with a single [CR]LF. | |
|
mmenke
2015/06/09 20:23:37
Suggest focusing on what it's used for, rather tha
haavardm
2015/06/10 11:54:02
Agree. I didn't take the http status into the equa
| |
| 156 static int LocateEndOfAdditionalHeaders(const char* buf, | |
| 157 int buf_len, | |
| 158 int i = 0); | |
| 159 | |
| 154 // Assemble "raw headers" in the format required by HttpResponseHeaders. | 160 // Assemble "raw headers" in the format required by HttpResponseHeaders. |
| 155 // This involves normalizing line terminators, converting [CR]LF to \0 and | 161 // This involves normalizing line terminators, converting [CR]LF to \0 and |
| 156 // handling HTTP line continuations (i.e., lines starting with LWS are | 162 // handling HTTP line continuations (i.e., lines starting with LWS are |
| 157 // continuations of the previous line). |buf_len| indicates the position of | 163 // continuations of the previous line). |buf_len| indicates the position of |
| 158 // the end-of-headers marker as defined by LocateEndOfHeaders. | 164 // the end-of-headers marker as defined by LocateEndOfHeaders. |
| 159 // If a \0 appears within the headers themselves, it will be stripped. This | 165 // If a \0 appears within the headers themselves, it will be stripped. This |
| 160 // is a workaround to avoid later code from incorrectly interpreting it as | 166 // is a workaround to avoid later code from incorrectly interpreting it as |
| 161 // a line terminator. | 167 // a line terminator. |
| 162 // | 168 // |
| 163 // TODO(eroman): we should use \n as the canonical line separator rather than | 169 // TODO(eroman): we should use \n as the canonical line separator rather than |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 // into the original's unquoted_value_ member. | 369 // into the original's unquoted_value_ member. |
| 364 std::string unquoted_value_; | 370 std::string unquoted_value_; |
| 365 | 371 |
| 366 bool value_is_quoted_; | 372 bool value_is_quoted_; |
| 367 }; | 373 }; |
| 368 }; | 374 }; |
| 369 | 375 |
| 370 } // namespace net | 376 } // namespace net |
| 371 | 377 |
| 372 #endif // NET_HTTP_HTTP_UTIL_H_ | 378 #endif // NET_HTTP_HTTP_UTIL_H_ |
| OLD | NEW |