| 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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 | 825 |
| 826 createRequest(httpBody.release(), exceptionState); | 826 createRequest(httpBody.release(), exceptionState); |
| 827 } | 827 } |
| 828 | 828 |
| 829 void XMLHttpRequest::sendForInspectorXHRReplay(PassRefPtr<FormData> formData, Ex
ceptionState& exceptionState) | 829 void XMLHttpRequest::sendForInspectorXHRReplay(PassRefPtr<FormData> formData, Ex
ceptionState& exceptionState) |
| 830 { | 830 { |
| 831 createRequest(formData ? formData->deepCopy() : nullptr, exceptionState); | 831 createRequest(formData ? formData->deepCopy() : nullptr, exceptionState); |
| 832 m_exceptionCode = exceptionState.code(); | 832 m_exceptionCode = exceptionState.code(); |
| 833 } | 833 } |
| 834 | 834 |
| 835 void XMLHttpRequest::throwForLoadFailureIfNeeded(ExceptionState& exceptionState,
const String& reason) |
| 836 { |
| 837 if (m_error && !m_exceptionCode) |
| 838 m_exceptionCode = NetworkError; |
| 839 |
| 840 if (!m_exceptionCode) |
| 841 return; |
| 842 |
| 843 String message = "Failed to load '" + m_url.elidedString() + "'"; |
| 844 if (reason.isNull()) { |
| 845 message.append("."); |
| 846 } else { |
| 847 message.append(": "); |
| 848 message.append(reason); |
| 849 } |
| 850 |
| 851 exceptionState.throwDOMException(m_exceptionCode, message); |
| 852 } |
| 853 |
| 835 void XMLHttpRequest::createRequest(PassRefPtr<FormData> httpBody, ExceptionState
& exceptionState) | 854 void XMLHttpRequest::createRequest(PassRefPtr<FormData> httpBody, ExceptionState
& exceptionState) |
| 836 { | 855 { |
| 837 // Only GET request is supported for blob URL. | 856 // Only GET request is supported for blob URL. |
| 838 if (m_url.protocolIs("blob") && m_method != "GET") { | 857 if (m_url.protocolIs("blob") && m_method != "GET") { |
| 839 exceptionState.throwDOMException(NetworkError, "'GET' is the only method
allowed for 'blob:' URLs."); | 858 handleNetworkError(); |
| 859 |
| 860 if (!m_async) { |
| 861 throwForLoadFailureIfNeeded(exceptionState, "'GET' is the only metho
d allowed for 'blob:' URLs."); |
| 862 } |
| 840 return; | 863 return; |
| 841 } | 864 } |
| 842 | 865 |
| 843 // The presence of upload event listeners forces us to use preflighting beca
use POSTing to an URL that does not | 866 // The presence of upload event listeners forces us to use preflighting beca
use POSTing to an URL that does not |
| 844 // permit cross origin requests should look exactly like POSTing to an URL t
hat does not respond at all. | 867 // permit cross origin requests should look exactly like POSTing to an URL t
hat does not respond at all. |
| 845 // Also, only async requests support upload progress events. | 868 // Also, only async requests support upload progress events. |
| 846 bool uploadEvents = false; | 869 bool uploadEvents = false; |
| 847 if (m_async) { | 870 if (m_async) { |
| 848 dispatchProgressEvent(EventTypeNames::loadstart, 0, 0); | 871 dispatchProgressEvent(EventTypeNames::loadstart, 0, 0); |
| 849 if (httpBody && m_upload) { | 872 if (httpBody && m_upload) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestAsynchron
ous); | 927 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestAsynchron
ous); |
| 905 if (m_upload) | 928 if (m_upload) |
| 906 request.setReportUploadProgress(true); | 929 request.setReportUploadProgress(true); |
| 907 | 930 |
| 908 // ThreadableLoader::create can return null here, for example if we're n
o longer attached to a page. | 931 // ThreadableLoader::create can return null here, for example if we're n
o longer attached to a page. |
| 909 // This is true while running onunload handlers. | 932 // This is true while running onunload handlers. |
| 910 // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload
, <http://bugs.webkit.org/show_bug.cgi?id=10904>. | 933 // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload
, <http://bugs.webkit.org/show_bug.cgi?id=10904>. |
| 911 // FIXME: Maybe create() can return null for other reasons too? | 934 // FIXME: Maybe create() can return null for other reasons too? |
| 912 ASSERT(!m_loader); | 935 ASSERT(!m_loader); |
| 913 m_loader = ThreadableLoader::create(executionContext, this, request, opt
ions, resourceLoaderOptions); | 936 m_loader = ThreadableLoader::create(executionContext, this, request, opt
ions, resourceLoaderOptions); |
| 914 } else { | 937 |
| 915 // Use count for XHR synchronous requests. | 938 return; |
| 916 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchrono
us); | |
| 917 ThreadableLoader::loadResourceSynchronously(executionContext, request, *
this, options, resourceLoaderOptions); | |
| 918 } | 939 } |
| 919 | 940 |
| 920 if (!m_exceptionCode && m_error) | 941 // Use count for XHR synchronous requests. |
| 921 m_exceptionCode = NetworkError; | 942 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous); |
| 922 if (m_exceptionCode) | 943 ThreadableLoader::loadResourceSynchronously(executionContext, request, *this
, options, resourceLoaderOptions); |
| 923 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m
_url.elidedString() + "'."); | 944 |
| 945 throwForLoadFailureIfNeeded(exceptionState, String()); |
| 924 } | 946 } |
| 925 | 947 |
| 926 void XMLHttpRequest::abort() | 948 void XMLHttpRequest::abort() |
| 927 { | 949 { |
| 928 WTF_LOG(Network, "XMLHttpRequest %p abort()", this); | 950 WTF_LOG(Network, "XMLHttpRequest %p abort()", this); |
| 929 | 951 |
| 930 // internalAbort() clears |m_loader|. Compute |sendFlag| now. | 952 // internalAbort() clears |m_loader|. Compute |sendFlag| now. |
| 931 // | 953 // |
| 932 // |sendFlag| corresponds to "the send() flag" defined in the XHR spec. | 954 // |sendFlag| corresponds to "the send() flag" defined in the XHR spec. |
| 933 // | 955 // |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 visitor->trace(m_responseDocumentParser); | 1689 visitor->trace(m_responseDocumentParser); |
| 1668 visitor->trace(m_progressEventThrottle); | 1690 visitor->trace(m_progressEventThrottle); |
| 1669 visitor->trace(m_upload); | 1691 visitor->trace(m_upload); |
| 1670 visitor->trace(m_blobLoader); | 1692 visitor->trace(m_blobLoader); |
| 1671 XMLHttpRequestEventTarget::trace(visitor); | 1693 XMLHttpRequestEventTarget::trace(visitor); |
| 1672 DocumentParserClient::trace(visitor); | 1694 DocumentParserClient::trace(visitor); |
| 1673 ActiveDOMObject::trace(visitor); | 1695 ActiveDOMObject::trace(visitor); |
| 1674 } | 1696 } |
| 1675 | 1697 |
| 1676 } // namespace blink | 1698 } // namespace blink |
| OLD | NEW |