| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 5 * Copyright (C) 2009 Google Inc. All rights reserved. | 5 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 6 * Copyright (C) 2011 Apple Inc. All Rights Reserved. | 6 * Copyright (C) 2011 Apple Inc. All Rights Reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 */ | 31 */ |
| 32 | 32 |
| 33 #include "platform/network/HTTPParsers.h" | 33 #include "platform/network/HTTPParsers.h" |
| 34 | 34 |
| 35 #include "net/http/http_content_disposition.h" |
| 35 #include "net/http/http_response_headers.h" | 36 #include "net/http/http_response_headers.h" |
| 36 #include "net/http/http_util.h" | 37 #include "net/http/http_util.h" |
| 37 #include "platform/json/JSONParser.h" | 38 #include "platform/json/JSONParser.h" |
| 38 #include "platform/loader/fetch/ResourceResponse.h" | 39 #include "platform/loader/fetch/ResourceResponse.h" |
| 39 #include "platform/weborigin/Suborigin.h" | 40 #include "platform/weborigin/Suborigin.h" |
| 40 #include "platform/wtf/DateMath.h" | 41 #include "platform/wtf/DateMath.h" |
| 41 #include "platform/wtf/MathExtras.h" | 42 #include "platform/wtf/MathExtras.h" |
| 42 #include "platform/wtf/text/CString.h" | 43 #include "platform/wtf/text/CString.h" |
| 43 #include "platform/wtf/text/CharacterNames.h" | 44 #include "platform/wtf/text/CharacterNames.h" |
| 44 #include "platform/wtf/text/ParsingUtilities.h" | 45 #include "platform/wtf/text/ParsingUtilities.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 if (characters.IsEmpty()) | 261 if (characters.IsEmpty()) |
| 261 return false; | 262 return false; |
| 262 for (unsigned i = 0; i < characters.length(); ++i) { | 263 for (unsigned i = 0; i < characters.length(); ++i) { |
| 263 UChar c = characters[i]; | 264 UChar c = characters[i]; |
| 264 if (c > 0x7F || !net::HttpUtil::IsTokenChar(c)) | 265 if (c > 0x7F || !net::HttpUtil::IsTokenChar(c)) |
| 265 return false; | 266 return false; |
| 266 } | 267 } |
| 267 return true; | 268 return true; |
| 268 } | 269 } |
| 269 | 270 |
| 270 ContentDispositionType GetContentDispositionType( | 271 bool IsContentDispositionAttachment(const String& content_disposition) { |
| 271 const String& content_disposition) { | 272 CString cstring(content_disposition.Utf8()); |
| 272 if (content_disposition.IsEmpty()) | 273 std::string string(cstring.data(), cstring.length()); |
| 273 return kContentDispositionNone; | 274 return net::HttpContentDisposition(string, std::string()).is_attachment(); |
| 274 | |
| 275 Vector<String> parameters; | |
| 276 content_disposition.Split(';', parameters); | |
| 277 | |
| 278 if (parameters.IsEmpty()) | |
| 279 return kContentDispositionNone; | |
| 280 | |
| 281 String disposition_type = parameters[0]; | |
| 282 disposition_type.StripWhiteSpace(); | |
| 283 | |
| 284 if (DeprecatedEqualIgnoringCase(disposition_type, "inline")) | |
| 285 return kContentDispositionInline; | |
| 286 | |
| 287 // Some broken sites just send bogus headers like | |
| 288 // | |
| 289 // Content-Disposition: ; filename="file" | |
| 290 // Content-Disposition: filename="file" | |
| 291 // Content-Disposition: name="file" | |
| 292 // | |
| 293 // without a disposition token... screen those out. | |
| 294 if (!IsValidHTTPToken(disposition_type)) | |
| 295 return kContentDispositionNone; | |
| 296 | |
| 297 // We have a content-disposition of "attachment" or unknown. | |
| 298 // RFC 2183, section 2.8 says that an unknown disposition | |
| 299 // value should be treated as "attachment" | |
| 300 return kContentDispositionAttachment; | |
| 301 } | 275 } |
| 302 | 276 |
| 303 bool ParseHTTPRefresh(const String& refresh, | 277 bool ParseHTTPRefresh(const String& refresh, |
| 304 CharacterMatchFunctionPtr matcher, | 278 CharacterMatchFunctionPtr matcher, |
| 305 double& delay, | 279 double& delay, |
| 306 String& url) { | 280 String& url) { |
| 307 unsigned len = refresh.length(); | 281 unsigned len = refresh.length(); |
| 308 unsigned pos = 0; | 282 unsigned pos = 0; |
| 309 matcher = matcher ? matcher : IsWhitespace; | 283 matcher = matcher ? matcher : IsWhitespace; |
| 310 | 284 |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 bool ParseContentRangeHeaderFor206(const String& content_range, | 844 bool ParseContentRangeHeaderFor206(const String& content_range, |
| 871 int64_t* first_byte_position, | 845 int64_t* first_byte_position, |
| 872 int64_t* last_byte_position, | 846 int64_t* last_byte_position, |
| 873 int64_t* instance_length) { | 847 int64_t* instance_length) { |
| 874 return net::HttpUtil::ParseContentRangeHeaderFor206( | 848 return net::HttpUtil::ParseContentRangeHeaderFor206( |
| 875 StringUTF8Adaptor(content_range).AsStringPiece(), first_byte_position, | 849 StringUTF8Adaptor(content_range).AsStringPiece(), first_byte_position, |
| 876 last_byte_position, instance_length); | 850 last_byte_position, instance_length); |
| 877 } | 851 } |
| 878 | 852 |
| 879 } // namespace blink | 853 } // namespace blink |
| OLD | NEW |