| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> | 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> |
| 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> | 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> |
| 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. |
| 6 * Copyright (C) 2012 Intel Corporation | 6 * Copyright (C) 2012 Intel Corporation |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 { | 215 { |
| 216 ASSERT(scriptExecutionContext()->isDocument()); | 216 ASSERT(scriptExecutionContext()->isDocument()); |
| 217 return static_cast<Document*>(scriptExecutionContext()); | 217 return static_cast<Document*>(scriptExecutionContext()); |
| 218 } | 218 } |
| 219 | 219 |
| 220 SecurityOrigin* XMLHttpRequest::securityOrigin() const | 220 SecurityOrigin* XMLHttpRequest::securityOrigin() const |
| 221 { | 221 { |
| 222 return m_securityOrigin ? m_securityOrigin.get() : scriptExecutionContext()-
>securityOrigin(); | 222 return m_securityOrigin ? m_securityOrigin.get() : scriptExecutionContext()-
>securityOrigin(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 #if ENABLE(DASHBOARD_SUPPORT) | |
| 226 bool XMLHttpRequest::usesDashboardBackwardCompatibilityMode() const | |
| 227 { | |
| 228 if (scriptExecutionContext()->isWorkerContext()) | |
| 229 return false; | |
| 230 Settings* settings = document()->settings(); | |
| 231 return settings && settings->usesDashboardBackwardCompatibilityMode(); | |
| 232 } | |
| 233 #endif | |
| 234 | |
| 235 XMLHttpRequest::State XMLHttpRequest::readyState() const | 225 XMLHttpRequest::State XMLHttpRequest::readyState() const |
| 236 { | 226 { |
| 237 return m_state; | 227 return m_state; |
| 238 } | 228 } |
| 239 | 229 |
| 240 String XMLHttpRequest::responseText(ExceptionCode& ec) | 230 String XMLHttpRequest::responseText(ExceptionCode& ec) |
| 241 { | 231 { |
| 242 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeText) { | 232 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeText) { |
| 243 ec = INVALID_STATE_ERR; | 233 ec = INVALID_STATE_ERR; |
| 244 return ""; | 234 return ""; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 void XMLHttpRequest::send(Document* document, ExceptionCode& ec) | 581 void XMLHttpRequest::send(Document* document, ExceptionCode& ec) |
| 592 { | 582 { |
| 593 ASSERT(document); | 583 ASSERT(document); |
| 594 | 584 |
| 595 if (!initSend(ec)) | 585 if (!initSend(ec)) |
| 596 return; | 586 return; |
| 597 | 587 |
| 598 if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily(
)) { | 588 if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily(
)) { |
| 599 String contentType = getRequestHeader("Content-Type"); | 589 String contentType = getRequestHeader("Content-Type"); |
| 600 if (contentType.isEmpty()) { | 590 if (contentType.isEmpty()) { |
| 601 #if ENABLE(DASHBOARD_SUPPORT) | 591 // FIXME: this should include the charset used for encoding. |
| 602 if (usesDashboardBackwardCompatibilityMode()) | 592 setRequestHeaderInternal("Content-Type", "application/xml"); |
| 603 setRequestHeaderInternal("Content-Type", "application/x-www-form
-urlencoded"); | |
| 604 else | |
| 605 #endif | |
| 606 // FIXME: this should include the charset used for encoding. | |
| 607 setRequestHeaderInternal("Content-Type", "application/xml"); | |
| 608 } | 593 } |
| 609 | 594 |
| 610 // FIXME: According to XMLHttpRequest Level 2, this should use the Docum
ent.innerHTML algorithm | 595 // FIXME: According to XMLHttpRequest Level 2, this should use the Docum
ent.innerHTML algorithm |
| 611 // from the HTML5 specification to serialize the document. | 596 // from the HTML5 specification to serialize the document. |
| 612 String body = createMarkup(document); | 597 String body = createMarkup(document); |
| 613 | 598 |
| 614 // FIXME: this should use value of document.inputEncoding to determine t
he encoding to use. | 599 // FIXME: this should use value of document.inputEncoding to determine t
he encoding to use. |
| 615 TextEncoding encoding = UTF8Encoding(); | 600 TextEncoding encoding = UTF8Encoding(); |
| 616 m_requestEntityBody = FormData::create(encoding.encode(body.characters()
, body.length(), EntitiesForUnencodables)); | 601 m_requestEntityBody = FormData::create(encoding.encode(body.characters()
, body.length(), EntitiesForUnencodables)); |
| 617 if (m_upload) | 602 if (m_upload) |
| 618 m_requestEntityBody->setAlwaysStream(true); | 603 m_requestEntityBody->setAlwaysStream(true); |
| 619 } | 604 } |
| 620 | 605 |
| 621 createRequest(ec); | 606 createRequest(ec); |
| 622 } | 607 } |
| 623 | 608 |
| 624 void XMLHttpRequest::send(const String& body, ExceptionCode& ec) | 609 void XMLHttpRequest::send(const String& body, ExceptionCode& ec) |
| 625 { | 610 { |
| 626 if (!initSend(ec)) | 611 if (!initSend(ec)) |
| 627 return; | 612 return; |
| 628 | 613 |
| 629 if (!body.isNull() && m_method != "GET" && m_method != "HEAD" && m_url.proto
colIsInHTTPFamily()) { | 614 if (!body.isNull() && m_method != "GET" && m_method != "HEAD" && m_url.proto
colIsInHTTPFamily()) { |
| 630 String contentType = getRequestHeader("Content-Type"); | 615 String contentType = getRequestHeader("Content-Type"); |
| 631 if (contentType.isEmpty()) { | 616 if (contentType.isEmpty()) { |
| 632 #if ENABLE(DASHBOARD_SUPPORT) | 617 setRequestHeaderInternal("Content-Type", "application/xml"); |
| 633 if (usesDashboardBackwardCompatibilityMode()) | |
| 634 setRequestHeaderInternal("Content-Type", "application/x-www-form
-urlencoded"); | |
| 635 else | |
| 636 #endif | |
| 637 setRequestHeaderInternal("Content-Type", "application/xml"); | |
| 638 } else { | 618 } else { |
| 639 replaceCharsetInMediaType(contentType, "UTF-8"); | 619 replaceCharsetInMediaType(contentType, "UTF-8"); |
| 640 m_requestHeaders.set("Content-Type", contentType); | 620 m_requestHeaders.set("Content-Type", contentType); |
| 641 } | 621 } |
| 642 | 622 |
| 643 m_requestEntityBody = FormData::create(UTF8Encoding().encode(body.charac
ters(), body.length(), EntitiesForUnencodables)); | 623 m_requestEntityBody = FormData::create(UTF8Encoding().encode(body.charac
ters(), body.length(), EntitiesForUnencodables)); |
| 644 if (m_upload) | 624 if (m_upload) |
| 645 m_requestEntityBody->setAlwaysStream(true); | 625 m_requestEntityBody->setAlwaysStream(true); |
| 646 } | 626 } |
| 647 | 627 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 } | 932 } |
| 953 | 933 |
| 954 void XMLHttpRequest::overrideMimeType(const String& override) | 934 void XMLHttpRequest::overrideMimeType(const String& override) |
| 955 { | 935 { |
| 956 m_mimeTypeOverride = override; | 936 m_mimeTypeOverride = override; |
| 957 } | 937 } |
| 958 | 938 |
| 959 void XMLHttpRequest::setRequestHeader(const AtomicString& name, const String& va
lue, ExceptionCode& ec) | 939 void XMLHttpRequest::setRequestHeader(const AtomicString& name, const String& va
lue, ExceptionCode& ec) |
| 960 { | 940 { |
| 961 if (m_state != OPENED || m_loader) { | 941 if (m_state != OPENED || m_loader) { |
| 962 #if ENABLE(DASHBOARD_SUPPORT) | |
| 963 if (usesDashboardBackwardCompatibilityMode()) | |
| 964 return; | |
| 965 #endif | |
| 966 | |
| 967 ec = INVALID_STATE_ERR; | 942 ec = INVALID_STATE_ERR; |
| 968 return; | 943 return; |
| 969 } | 944 } |
| 970 | 945 |
| 971 if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(value)) { | 946 if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(value)) { |
| 972 ec = SYNTAX_ERR; | 947 ec = SYNTAX_ERR; |
| 973 return; | 948 return; |
| 974 } | 949 } |
| 975 | 950 |
| 976 // A privileged script (e.g. a Dashboard widget) can set any headers. | 951 // A privileged script can set any headers. |
| 977 if (!securityOrigin()->canLoadLocalResources() && !isAllowedHTTPHeader(name)
) { | 952 if (!securityOrigin()->canLoadLocalResources() && !isAllowedHTTPHeader(name)
) { |
| 978 logConsoleError(scriptExecutionContext(), "Refused to set unsafe header
\"" + name + "\""); | 953 logConsoleError(scriptExecutionContext(), "Refused to set unsafe header
\"" + name + "\""); |
| 979 return; | 954 return; |
| 980 } | 955 } |
| 981 | 956 |
| 982 setRequestHeaderInternal(name, value); | 957 setRequestHeaderInternal(name, value); |
| 983 } | 958 } |
| 984 | 959 |
| 985 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const St
ring& value) | 960 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const St
ring& value) |
| 986 { | 961 { |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 info.addMember(m_responseDocument, "responseDocument"); | 1317 info.addMember(m_responseDocument, "responseDocument"); |
| 1343 info.addMember(m_binaryResponseBuilder, "binaryResponseBuilder"); | 1318 info.addMember(m_binaryResponseBuilder, "binaryResponseBuilder"); |
| 1344 info.addMember(m_responseArrayBuffer, "responseArrayBuffer"); | 1319 info.addMember(m_responseArrayBuffer, "responseArrayBuffer"); |
| 1345 info.addMember(m_lastSendURL, "lastSendURL"); | 1320 info.addMember(m_lastSendURL, "lastSendURL"); |
| 1346 info.addMember(m_eventTargetData, "eventTargetData"); | 1321 info.addMember(m_eventTargetData, "eventTargetData"); |
| 1347 info.addMember(m_progressEventThrottle, "progressEventThrottle"); | 1322 info.addMember(m_progressEventThrottle, "progressEventThrottle"); |
| 1348 info.addMember(m_securityOrigin, "securityOrigin"); | 1323 info.addMember(m_securityOrigin, "securityOrigin"); |
| 1349 } | 1324 } |
| 1350 | 1325 |
| 1351 } // namespace WebCore | 1326 } // namespace WebCore |
| OLD | NEW |