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 David Levin <levin@chromium.org> | 5 * Copyright (C) 2008 David Levin <levin@chromium.org> |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 721 |
722 void XMLHttpRequest::networkError() | 722 void XMLHttpRequest::networkError() |
723 { | 723 { |
724 genericError(); | 724 genericError(); |
725 dispatchErrorEvent(); | 725 dispatchErrorEvent(); |
726 if (!m_uploadComplete) { | 726 if (!m_uploadComplete) { |
727 m_uploadComplete = true; | 727 m_uploadComplete = true; |
728 if (m_upload) | 728 if (m_upload) |
729 m_upload->dispatchErrorEvent(); | 729 m_upload->dispatchErrorEvent(); |
730 } | 730 } |
| 731 internalAbort(); |
731 } | 732 } |
732 | 733 |
733 void XMLHttpRequest::abortError() | 734 void XMLHttpRequest::abortError() |
734 { | 735 { |
735 genericError(); | 736 genericError(); |
736 dispatchAbortEvent(); | 737 dispatchAbortEvent(); |
737 if (!m_uploadComplete) { | 738 if (!m_uploadComplete) { |
738 m_uploadComplete = true; | 739 m_uploadComplete = true; |
739 if (m_upload) | 740 if (m_upload) |
740 m_upload->dispatchAbortEvent(); | 741 m_upload->dispatchAbortEvent(); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 // Firefox only raises an exception in this state; we match it. | 905 // Firefox only raises an exception in this state; we match it. |
905 // Note the case of local file requests, where we have no HTTP response
code! Firefox never raises an exception for those, but we match HTTP case for co
nsistency. | 906 // Note the case of local file requests, where we have no HTTP response
code! Firefox never raises an exception for those, but we match HTTP case for co
nsistency. |
906 ec = INVALID_STATE_ERR; | 907 ec = INVALID_STATE_ERR; |
907 } | 908 } |
908 | 909 |
909 return 0; | 910 return 0; |
910 } | 911 } |
911 | 912 |
912 String XMLHttpRequest::statusText(ExceptionCode& ec) const | 913 String XMLHttpRequest::statusText(ExceptionCode& ec) const |
913 { | 914 { |
914 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=3547> XMLHttpRequest.statu
sText returns always "OK". | 915 if (!m_response.httpStatusText().isNull()) |
915 if (m_response.httpStatusCode()) | 916 return m_response.httpStatusText(); |
916 return "OK"; | |
917 | 917 |
918 if (m_state == OPENED) { | 918 if (m_state == OPENED) { |
919 // See comments in getStatus() above. | 919 // See comments in status() above. |
920 ec = INVALID_STATE_ERR; | 920 ec = INVALID_STATE_ERR; |
921 } | 921 } |
922 | 922 |
923 return String(); | 923 return String(); |
924 } | 924 } |
925 | 925 |
926 void XMLHttpRequest::didFail(const ResourceError& error) | 926 void XMLHttpRequest::didFail(const ResourceError& error) |
927 { | 927 { |
928 // If we are already in an error state, for instance we called abort(), bail
out early. | 928 // If we are already in an error state, for instance we called abort(), bail
out early. |
929 if (m_error) | 929 if (m_error) |
930 return; | 930 return; |
931 | 931 |
932 if (error.isCancellation()) { | 932 if (error.isCancellation()) { |
933 m_exceptionCode = XMLHttpRequestException::ABORT_ERR; | 933 m_exceptionCode = XMLHttpRequestException::ABORT_ERR; |
934 abortError(); | 934 abortError(); |
935 return; | 935 return; |
936 } | 936 } |
937 | 937 |
938 m_exceptionCode = XMLHttpRequestException::NETWORK_ERR; | 938 m_exceptionCode = XMLHttpRequestException::NETWORK_ERR; |
939 networkError(); | 939 networkError(); |
940 } | 940 } |
941 | 941 |
942 void XMLHttpRequest::didFailRedirectCheck() | 942 void XMLHttpRequest::didFailRedirectCheck() |
943 { | 943 { |
944 internalAbort(); | |
945 networkError(); | 944 networkError(); |
946 } | 945 } |
947 | 946 |
948 void XMLHttpRequest::didFinishLoading(unsigned long identifier) | 947 void XMLHttpRequest::didFinishLoading(unsigned long identifier) |
949 { | 948 { |
950 if (m_error) | 949 if (m_error) |
951 return; | 950 return; |
952 | 951 |
953 if (m_inPreflight) { | 952 if (m_inPreflight) { |
954 didFinishLoadingPreflight(); | 953 didFinishLoadingPreflight(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 CrossOriginPreflightResultCache::shared().appendEntry(scriptExecutionContext
()->securityOrigin()->toString(), m_url, preflightResult.release()); | 1040 CrossOriginPreflightResultCache::shared().appendEntry(scriptExecutionContext
()->securityOrigin()->toString(), m_url, preflightResult.release()); |
1042 } | 1041 } |
1043 | 1042 |
1044 void XMLHttpRequest::didReceiveAuthenticationCancellation(const ResourceResponse
& failureResponse) | 1043 void XMLHttpRequest::didReceiveAuthenticationCancellation(const ResourceResponse
& failureResponse) |
1045 { | 1044 { |
1046 m_response = failureResponse; | 1045 m_response = failureResponse; |
1047 } | 1046 } |
1048 | 1047 |
1049 void XMLHttpRequest::didReceiveData(const char* data, int len) | 1048 void XMLHttpRequest::didReceiveData(const char* data, int len) |
1050 { | 1049 { |
1051 if (m_inPreflight) | 1050 if (m_inPreflight || m_error) |
1052 return; | 1051 return; |
1053 | 1052 |
1054 if (m_state < HEADERS_RECEIVED) | 1053 if (m_state < HEADERS_RECEIVED) |
1055 changeState(HEADERS_RECEIVED); | 1054 changeState(HEADERS_RECEIVED); |
1056 | 1055 |
1057 if (!m_decoder) { | 1056 if (!m_decoder) { |
1058 if (!m_responseEncoding.isEmpty()) | 1057 if (!m_responseEncoding.isEmpty()) |
1059 m_decoder = TextResourceDecoder::create("text/plain", m_responseEnco
ding); | 1058 m_decoder = TextResourceDecoder::create("text/plain", m_responseEnco
ding); |
1060 // allow TextResourceDecoder to look inside the m_response if it's XML o
r HTML | 1059 // allow TextResourceDecoder to look inside the m_response if it's XML o
r HTML |
1061 else if (responseIsXML()) { | 1060 else if (responseIsXML()) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 ASSERT(!m_loader); | 1165 ASSERT(!m_loader); |
1167 ActiveDOMObject::contextDestroyed(); | 1166 ActiveDOMObject::contextDestroyed(); |
1168 } | 1167 } |
1169 | 1168 |
1170 ScriptExecutionContext* XMLHttpRequest::scriptExecutionContext() const | 1169 ScriptExecutionContext* XMLHttpRequest::scriptExecutionContext() const |
1171 { | 1170 { |
1172 return ActiveDOMObject::scriptExecutionContext(); | 1171 return ActiveDOMObject::scriptExecutionContext(); |
1173 } | 1172 } |
1174 | 1173 |
1175 } // namespace WebCore | 1174 } // namespace WebCore |
OLD | NEW |