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/StdLibExtras.h" | 10 #include "wtf/StdLibExtras.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 // Copy the response headers from the original response. | 186 // Copy the response headers from the original response. |
187 for (const auto& header : m_originalResponse.httpHeaderFields()) { | 187 for (const auto& header : m_originalResponse.httpHeaderFields()) { |
188 bool forbidden = false; | 188 bool forbidden = false; |
189 for (size_t i = 0; !forbidden && i < WTF_ARRAY_LENGTH(kReplaceHeaders);
++i) | 189 for (size_t i = 0; !forbidden && i < WTF_ARRAY_LENGTH(kReplaceHeaders);
++i) |
190 forbidden = equalIgnoringCase(header.key, kReplaceHeaders[i]); | 190 forbidden = equalIgnoringCase(header.key, kReplaceHeaders[i]); |
191 if (!forbidden) | 191 if (!forbidden) |
192 response.addHTTPHeaderField(header.key, header.value); | 192 response.addHTTPHeaderField(header.key, header.value); |
193 } | 193 } |
194 | 194 |
195 // To avoid recording every multipart load as a separate visit in | 195 bool isFirstPart = m_isFirstPart; |
196 // the history database, we want to keep track of whether the response | |
197 // is part of a multipart payload. We do want to record the first visit, | |
198 // so we only set isMultipartPayload to true after the first visit. | |
199 response.setIsMultipartPayload(!m_isFirstPart); | |
200 m_isFirstPart = false; | 196 m_isFirstPart = false; |
201 // Send the response! | 197 // Send the response! |
202 m_client->didReceiveResponse(response.toResourceResponse()); | 198 m_client->didReceiveResponse(response.toResourceResponse(), isFirstPart); |
203 | 199 |
204 return true; | 200 return true; |
205 } | 201 } |
206 | 202 |
207 // Boundaries are supposed to be preceeded with --, but it looks like gecko | 203 // Boundaries are supposed to be preceeded with --, but it looks like gecko |
208 // doesn't require the dashes to exist. See nsMultiMixedConv::FindToken. | 204 // doesn't require the dashes to exist. See nsMultiMixedConv::FindToken. |
209 size_t MultipartImageResourceParser::findBoundary(const Vector<char>& data, Vect
or<char>* boundary) | 205 size_t MultipartImageResourceParser::findBoundary(const Vector<char>& data, Vect
or<char>* boundary) |
210 { | 206 { |
211 size_t boundaryPosition = find(data.data(), data.size(), boundary->data(), b
oundary->size()); | 207 size_t boundaryPosition = find(data.data(), data.size(), boundary->data(), b
oundary->size()); |
212 if (boundaryPosition != kNotFound) { | 208 if (boundaryPosition != kNotFound) { |
(...skipping 11 matching lines...) Expand all Loading... |
224 } | 220 } |
225 return boundaryPosition; | 221 return boundaryPosition; |
226 } | 222 } |
227 | 223 |
228 DEFINE_TRACE(MultipartImageResourceParser) | 224 DEFINE_TRACE(MultipartImageResourceParser) |
229 { | 225 { |
230 visitor->trace(m_client); | 226 visitor->trace(m_client); |
231 } | 227 } |
232 | 228 |
233 } // namespace blink | 229 } // namespace blink |
OLD | NEW |