OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "core/fetch/MultipartImageResourceParser.h" | 5 #include "core/fetch/MultipartImageResourceParser.h" |
6 | 6 |
7 #include "public/platform/Platform.h" | 7 #include "public/platform/Platform.h" |
8 #include "public/platform/WebURLResponse.h" | 8 #include "public/platform/WebURLResponse.h" |
9 #include "wtf/NotFound.h" | 9 #include "wtf/NotFound.h" |
10 #include "wtf/text/WTFString.h" | 10 #include "wtf/text/WTFString.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // does. See netwerk/streamconv/converters/nsMultiMixedConv.cpp. | 151 // does. See netwerk/streamconv/converters/nsMultiMixedConv.cpp. |
152 WebURLResponse response(m_originalResponse.url()); | 152 WebURLResponse response(m_originalResponse.url()); |
153 for (const auto& header : m_originalResponse.httpHeaderFields()) | 153 for (const auto& header : m_originalResponse.httpHeaderFields()) |
154 response.addHTTPHeaderField(header.key, header.value); | 154 response.addHTTPHeaderField(header.key, header.value); |
155 | 155 |
156 size_t end = 0; | 156 size_t end = 0; |
157 if (!Platform::current()->parseMultipartHeadersFromBody(m_data.data(), m_dat
a.size(), &response, &end)) | 157 if (!Platform::current()->parseMultipartHeadersFromBody(m_data.data(), m_dat
a.size(), &response, &end)) |
158 return false; | 158 return false; |
159 m_data.remove(0, end); | 159 m_data.remove(0, end); |
160 | 160 |
161 // To avoid recording every multipart load as a separate visit in | 161 bool isFirstPart = m_isFirstPart; |
162 // the history database, we want to keep track of whether the response | |
163 // is part of a multipart payload. We do want to record the first visit, | |
164 // so we only set isMultipartPayload to true after the first visit. | |
165 response.setIsMultipartPayload(!m_isFirstPart); | |
166 m_isFirstPart = false; | 162 m_isFirstPart = false; |
167 // Send the response! | 163 // Send the response! |
168 m_client->onePartInMultipartReceived(response.toResourceResponse()); | 164 m_client->onePartInMultipartReceived(response.toResourceResponse(), isFirstP
art); |
169 | 165 |
170 return true; | 166 return true; |
171 } | 167 } |
172 | 168 |
173 // Boundaries are supposed to be preceeded with --, but it looks like gecko | 169 // Boundaries are supposed to be preceeded with --, but it looks like gecko |
174 // doesn't require the dashes to exist. See nsMultiMixedConv::FindToken. | 170 // doesn't require the dashes to exist. See nsMultiMixedConv::FindToken. |
175 size_t MultipartImageResourceParser::findBoundary(const Vector<char>& data, Vect
or<char>* boundary) | 171 size_t MultipartImageResourceParser::findBoundary(const Vector<char>& data, Vect
or<char>* boundary) |
176 { | 172 { |
177 auto it = std::search(data.data(), data.data() + data.size(), boundary->data
(), boundary->data() + boundary->size()); | 173 auto it = std::search(data.data(), data.data() + data.size(), boundary->data
(), boundary->data() + boundary->size()); |
178 if (it == data.data() + data.size()) | 174 if (it == data.data() + data.size()) |
(...skipping 13 matching lines...) Expand all Loading... |
192 } | 188 } |
193 return boundaryPosition; | 189 return boundaryPosition; |
194 } | 190 } |
195 | 191 |
196 DEFINE_TRACE(MultipartImageResourceParser) | 192 DEFINE_TRACE(MultipartImageResourceParser) |
197 { | 193 { |
198 visitor->trace(m_client); | 194 visitor->trace(m_client); |
199 } | 195 } |
200 | 196 |
201 } // namespace blink | 197 } // namespace blink |
OLD | NEW |