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

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

Issue 7796025: Don't interpret embeded NULLs in a response header line as a line terminator. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address wtc comments Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_response_headers.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // ASIS Apache module). This function therefore accepts the pattern LF[CR]LF 124 // ASIS Apache module). This function therefore accepts the pattern LF[CR]LF
125 // as end-of-headers (just like Mozilla). 125 // as end-of-headers (just like Mozilla).
126 // The parameter |i| is the offset within |buf| to begin searching from. 126 // The parameter |i| is the offset within |buf| to begin searching from.
127 static int LocateEndOfHeaders(const char* buf, int buf_len, int i = 0); 127 static int LocateEndOfHeaders(const char* buf, int buf_len, int i = 0);
128 128
129 // Assemble "raw headers" in the format required by HttpResponseHeaders. 129 // Assemble "raw headers" in the format required by HttpResponseHeaders.
130 // This involves normalizing line terminators, converting [CR]LF to \0 and 130 // This involves normalizing line terminators, converting [CR]LF to \0 and
131 // handling HTTP line continuations (i.e., lines starting with LWS are 131 // handling HTTP line continuations (i.e., lines starting with LWS are
132 // continuations of the previous line). |buf_len| indicates the position of 132 // continuations of the previous line). |buf_len| indicates the position of
133 // the end-of-headers marker as defined by LocateEndOfHeaders. 133 // the end-of-headers marker as defined by LocateEndOfHeaders.
134 // If a \0 appears within the headers themselves, it will be stripped. This
135 // is a workaround to avoid later code from incorrectly interpreting it as
136 // a line terminator.
137 //
138 // TODO(eroman): we should use \n as the canonical line separator rather than
139 // \0 to avoid this problem. Unfortunately the persistence layer
140 // is already dependent on newlines being replaced by NULL so
141 // this is hard to change without breaking things.
134 static std::string AssembleRawHeaders(const char* buf, int buf_len); 142 static std::string AssembleRawHeaders(const char* buf, int buf_len);
135 143
136 // Converts assembled "raw headers" back to the HTTP response format. That is 144 // Converts assembled "raw headers" back to the HTTP response format. That is
137 // convert each \0 occurence to CRLF. This is used by DevTools. 145 // convert each \0 occurence to CRLF. This is used by DevTools.
138 // Since all line continuations info is already lost at this point, the result 146 // Since all line continuations info is already lost at this point, the result
139 // consists of status line and then one line for each header. 147 // consists of status line and then one line for each header.
140 static std::string ConvertHeadersBackToHTTPResponse(const std::string& str); 148 static std::string ConvertHeadersBackToHTTPResponse(const std::string& str);
141 149
142 // Given a comma separated ordered list of language codes, return 150 // Given a comma separated ordered list of language codes, return
143 // the list with a qvalue appended to each language. 151 // the list with a qvalue appended to each language.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // into the original's unquoted_value_ member. 326 // into the original's unquoted_value_ member.
319 std::string unquoted_value_; 327 std::string unquoted_value_;
320 328
321 bool value_is_quoted_; 329 bool value_is_quoted_;
322 }; 330 };
323 }; 331 };
324 332
325 } // namespace net 333 } // namespace net
326 334
327 #endif // NET_HTTP_HTTP_UTIL_H_ 335 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698