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

Side by Side Diff: net/http/http_util.h

Issue 1166953002: Use net's response header parser for parsing multipart headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address more comments Created 5 years, 6 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 | « content/child/multipart_response_delegate.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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). The first line of |buf| is
151 // considered the status line, even if empty.
151 // The parameter |i| is the offset within |buf| to begin searching from. 152 // 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); 153 static int LocateEndOfHeaders(const char* buf, int buf_len, int i = 0);
153 154
155 // Same as |LocateEndOfHeaders|, but does not expect a status line, so can be
156 // used on multi-part responses or HTTP/1.x trailers. As a result, if |buf|
157 // starts with a single [CR]LF, it is considered an empty header list, as
158 // opposed to an empty status line above a header list.
159 static int LocateEndOfAdditionalHeaders(const char* buf,
160 int buf_len,
161 int i = 0);
162
154 // Assemble "raw headers" in the format required by HttpResponseHeaders. 163 // Assemble "raw headers" in the format required by HttpResponseHeaders.
155 // This involves normalizing line terminators, converting [CR]LF to \0 and 164 // This involves normalizing line terminators, converting [CR]LF to \0 and
156 // handling HTTP line continuations (i.e., lines starting with LWS are 165 // handling HTTP line continuations (i.e., lines starting with LWS are
157 // continuations of the previous line). |buf_len| indicates the position of 166 // continuations of the previous line). |buf_len| indicates the position of
158 // the end-of-headers marker as defined by LocateEndOfHeaders. 167 // the end-of-headers marker as defined by LocateEndOfHeaders.
159 // If a \0 appears within the headers themselves, it will be stripped. This 168 // 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 169 // is a workaround to avoid later code from incorrectly interpreting it as
161 // a line terminator. 170 // a line terminator.
162 // 171 //
163 // TODO(eroman): we should use \n as the canonical line separator rather than 172 // 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
363 // into the original's unquoted_value_ member. 372 // into the original's unquoted_value_ member.
364 std::string unquoted_value_; 373 std::string unquoted_value_;
365 374
366 bool value_is_quoted_; 375 bool value_is_quoted_;
367 }; 376 };
368 }; 377 };
369 378
370 } // namespace net 379 } // namespace net
371 380
372 #endif // NET_HTTP_HTTP_UTIL_H_ 381 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW
« no previous file with comments | « content/child/multipart_response_delegate.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698