| 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 13 matching lines...) Expand all Loading... |
| 24 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 24 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 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 "config.h" | 33 #include "config.h" |
| 34 #include "core/platform/network/HTTPParsers.h" | 34 #include "platform/network/HTTPParsers.h" |
| 35 | 35 |
| 36 #include "wtf/DateMath.h" | 36 #include "wtf/DateMath.h" |
| 37 #include "wtf/text/CString.h" | 37 #include "wtf/text/CString.h" |
| 38 #include "wtf/text/StringBuilder.h" | 38 #include "wtf/text/StringBuilder.h" |
| 39 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
| 40 #include "wtf/unicode/CharacterNames.h" | 40 #include "wtf/unicode/CharacterNames.h" |
| 41 | 41 |
| 42 using namespace WTF; | 42 using namespace WTF; |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 ++pos; | 193 ++pos; |
| 194 skipWhiteSpace(refresh, pos, fromHttpEquivMeta); | 194 skipWhiteSpace(refresh, pos, fromHttpEquivMeta); |
| 195 unsigned urlStartPos = pos; | 195 unsigned urlStartPos = pos; |
| 196 if (refresh.find("url", urlStartPos, false) == urlStartPos) { | 196 if (refresh.find("url", urlStartPos, false) == urlStartPos) { |
| 197 urlStartPos += 3; | 197 urlStartPos += 3; |
| 198 skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); | 198 skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); |
| 199 if (refresh[urlStartPos] == '=') { | 199 if (refresh[urlStartPos] == '=') { |
| 200 ++urlStartPos; | 200 ++urlStartPos; |
| 201 skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); | 201 skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); |
| 202 } else | 202 } else { |
| 203 urlStartPos = pos; // e.g. "Refresh: 0; url.html" | 203 urlStartPos = pos; // e.g. "Refresh: 0; url.html" |
| 204 } |
| 204 } | 205 } |
| 205 | 206 |
| 206 unsigned urlEndPos = len; | 207 unsigned urlEndPos = len; |
| 207 | 208 |
| 208 if (refresh[urlStartPos] == '"' || refresh[urlStartPos] == '\'') { | 209 if (refresh[urlStartPos] == '"' || refresh[urlStartPos] == '\'') { |
| 209 UChar quotationMark = refresh[urlStartPos]; | 210 UChar quotationMark = refresh[urlStartPos]; |
| 210 urlStartPos++; | 211 urlStartPos++; |
| 211 while (urlEndPos > urlStartPos) { | 212 while (urlEndPos > urlStartPos) { |
| 212 urlEndPos--; | 213 urlEndPos--; |
| 213 if (refresh[urlEndPos] == quotationMark) | 214 if (refresh[urlEndPos] == quotationMark) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 mimeType.append(c); | 296 mimeType.append(c); |
| 296 } | 297 } |
| 297 | 298 |
| 298 if (mimeType.length() == length) | 299 if (mimeType.length() == length) |
| 299 return mediaType; | 300 return mediaType; |
| 300 return mimeType.toString(); | 301 return mimeType.toString(); |
| 301 } | 302 } |
| 302 | 303 |
| 303 String extractCharsetFromMediaType(const String& mediaType) | 304 String extractCharsetFromMediaType(const String& mediaType) |
| 304 { | 305 { |
| 305 unsigned int pos, len; | 306 unsigned pos, len; |
| 306 findCharsetInMediaType(mediaType, pos, len); | 307 findCharsetInMediaType(mediaType, pos, len); |
| 307 return mediaType.substring(pos, len); | 308 return mediaType.substring(pos, len); |
| 308 } | 309 } |
| 309 | 310 |
| 310 void findCharsetInMediaType(const String& mediaType, unsigned int& charsetPos, u
nsigned int& charsetLen, unsigned int start) | 311 void findCharsetInMediaType(const String& mediaType, unsigned& charsetPos, unsig
ned& charsetLen, unsigned start) |
| 311 { | 312 { |
| 312 charsetPos = start; | 313 charsetPos = start; |
| 313 charsetLen = 0; | 314 charsetLen = 0; |
| 314 | 315 |
| 315 size_t pos = start; | 316 size_t pos = start; |
| 316 unsigned length = mediaType.length(); | 317 unsigned length = mediaType.length(); |
| 317 | 318 |
| 318 while (pos < length) { | 319 while (pos < length) { |
| 319 pos = mediaType.find("charset", pos, false); | 320 pos = mediaType.find("charset", pos, false); |
| 320 if (pos == kNotFound || !pos) { | 321 if (pos == kNotFound || !pos) { |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 const char* space2 = 0; | 556 const char* space2 = 0; |
| 556 const char* p; | 557 const char* p; |
| 557 size_t consumedLength; | 558 size_t consumedLength; |
| 558 | 559 |
| 559 for (p = data, consumedLength = 0; consumedLength < length; p++, consumedLen
gth++) { | 560 for (p = data, consumedLength = 0; consumedLength < length; p++, consumedLen
gth++) { |
| 560 if (*p == ' ') { | 561 if (*p == ' ') { |
| 561 if (!space1) | 562 if (!space1) |
| 562 space1 = p; | 563 space1 = p; |
| 563 else if (!space2) | 564 else if (!space2) |
| 564 space2 = p; | 565 space2 = p; |
| 565 } else if (*p == '\n') | 566 } else if (*p == '\n') { |
| 566 break; | 567 break; |
| 568 } |
| 567 } | 569 } |
| 568 | 570 |
| 569 // Haven't finished header line. | 571 // Haven't finished header line. |
| 570 if (consumedLength == length) { | 572 if (consumedLength == length) { |
| 571 failureReason = "Incomplete Request Line"; | 573 failureReason = "Incomplete Request Line"; |
| 572 return 0; | 574 return 0; |
| 573 } | 575 } |
| 574 | 576 |
| 575 // RequestLine does not contain 3 parts. | 577 // RequestLine does not contain 3 parts. |
| 576 if (!space1 || !space2) { | 578 if (!space1 || !space2) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 | 679 |
| 678 size_t parseHTTPRequestBody(const char* data, size_t length, Vector<unsigned cha
r>& body) | 680 size_t parseHTTPRequestBody(const char* data, size_t length, Vector<unsigned cha
r>& body) |
| 679 { | 681 { |
| 680 body.clear(); | 682 body.clear(); |
| 681 body.append(data, length); | 683 body.append(data, length); |
| 682 | 684 |
| 683 return length; | 685 return length; |
| 684 } | 686 } |
| 685 | 687 |
| 686 } | 688 } |
| OLD | NEW |