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

Unified Diff: webkit/glue/multipart_response_delegate.cc

Issue 2896: This CB fixes the following issues:-... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/multipart_response_delegate.h ('k') | webkit/glue/multipart_response_delegate_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/multipart_response_delegate.cc
===================================================================
--- webkit/glue/multipart_response_delegate.cc (revision 2387)
+++ webkit/glue/multipart_response_delegate.cc (working copy)
@@ -72,6 +72,11 @@
// Headers
if (processing_headers_) {
+ // Eat leading \r\n
+ int pos = PushOverLine(data_, 0);
+ if (pos)
+ data_ = data_.substr(pos);
+
if (ParseHeaders()) {
// Successfully parsed headers.
processing_headers_ = false;
@@ -227,3 +232,78 @@
return boundary_pos;
}
+bool MultipartResponseDelegate::ReadMultipartBoundary(
+ const WebCore::ResourceResponse& response,
+ std::string* multipart_boundary) {
+
+ WebCore::String content_type = response.httpHeaderField("Content-Type");
+ std::string content_type_as_string =
+ webkit_glue::StringToStdString(content_type);
+
+ size_t boundary_start_offset = content_type_as_string.find("boundary=");
+ if (boundary_start_offset == std::wstring::npos) {
+ return false;
+ }
+
+ boundary_start_offset += strlen("boundary=");
+ size_t boundary_end_offset = content_type.length();
+
+ size_t boundary_length = boundary_end_offset - boundary_start_offset;
+
+ *multipart_boundary =
+ content_type_as_string.substr(boundary_start_offset, boundary_length);
+ return true;
+}
+
+bool MultipartResponseDelegate::ReadContentRanges(
+ const WebCore::ResourceResponse& response,
+ int* content_range_lower_bound,
+ int* content_range_upper_bound) {
+
+ std::string content_range =
+ webkit_glue::StringToStdString(
+ response.httpHeaderField("Content-Range"));
+
+ size_t byte_range_lower_bound_start_offset =
+ content_range.find(" ");
+ if (byte_range_lower_bound_start_offset == std::string::npos) {
+ return false;
+ }
+
+ // Skip over the initial space.
+ byte_range_lower_bound_start_offset++;
+
+ size_t byte_range_lower_bound_end_offset =
+ content_range.find("-", byte_range_lower_bound_start_offset);
+ if (byte_range_lower_bound_end_offset == std::string::npos) {
+ return false;
+ }
+
+ size_t byte_range_lower_bound_characters =
+ byte_range_lower_bound_end_offset - byte_range_lower_bound_start_offset;
+ std::string byte_range_lower_bound =
+ content_range.substr(byte_range_lower_bound_start_offset,
+ byte_range_lower_bound_characters);
+
+ size_t byte_range_upper_bound_start_offset =
+ byte_range_lower_bound_end_offset + 1;
+
+ size_t byte_range_upper_bound_end_offset =
+ content_range.find("/", byte_range_upper_bound_start_offset);
+ if (byte_range_upper_bound_end_offset == std::string::npos) {
+ return false;
+ }
+
+ size_t byte_range_upper_bound_characters =
+ byte_range_upper_bound_end_offset - byte_range_upper_bound_start_offset;
+
+ std::string byte_range_upper_bound =
+ content_range.substr(byte_range_upper_bound_start_offset,
+ byte_range_upper_bound_characters);
+
+ if (!StringToInt(byte_range_lower_bound, content_range_lower_bound))
+ return false;
+ if (!StringToInt(byte_range_upper_bound, content_range_upper_bound))
+ return false;
+ return true;
+}
« no previous file with comments | « webkit/glue/multipart_response_delegate.h ('k') | webkit/glue/multipart_response_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698