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

Unified Diff: net/http/http_util.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util.cc
diff --git a/net/http/http_util.cc b/net/http/http_util.cc
index baa2eff1043a34926c328be9eeadf15d08cbf3cd..5d314d12f688d3aef71f2c2686e83962d7666825 100644
--- a/net/http/http_util.cc
+++ b/net/http/http_util.cc
@@ -542,9 +542,19 @@ int HttpUtil::LocateStartOfStatusLine(const char* buf, int buf_len) {
return -1; // Not found
}
-int HttpUtil::LocateEndOfHeaders(const char* buf, int buf_len, int i) {
- bool was_lf = false;
+static int LocateEndOfHeadersHelper(const char* buf,
+ int buf_len,
+ int i,
+ bool accept_empty_header_list) {
char last_c = '\0';
+ bool was_lf = false;
+ if (accept_empty_header_list) {
+ // Normally two line breaks signal the end of a header list. An empty header
+ // list ends with a single line break at the start of the buffer.
+ last_c = '\n';
+ was_lf = true;
+ }
+
for (; i < buf_len; ++i) {
char c = buf[i];
if (c == '\n') {
@@ -559,6 +569,16 @@ int HttpUtil::LocateEndOfHeaders(const char* buf, int buf_len, int i) {
return -1;
}
+int HttpUtil::LocateEndOfAdditionalHeaders(const char* buf,
+ int buf_len,
+ int i) {
+ return LocateEndOfHeadersHelper(buf, buf_len, i, true);
+}
+
+int HttpUtil::LocateEndOfHeaders(const char* buf, int buf_len, int i) {
+ return LocateEndOfHeadersHelper(buf, buf_len, i, false);
+}
+
// In order for a line to be continuable, it must specify a
// non-blank header-name. Line continuations are specifically for
// header values -- do not allow headers names to span lines.
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698