| 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 if (getRequestHeader(HTTPNames::Content_Type).isEmpty()) | 763 if (getRequestHeader(HTTPNames::Content_Type).isEmpty()) |
| 764 setRequestHeaderInternal(HTTPNames::Content_Type, | 764 setRequestHeaderInternal(HTTPNames::Content_Type, |
| 765 "application/xml;charset=UTF-8"); | 765 "application/xml;charset=UTF-8"); |
| 766 | 766 |
| 767 String body = createMarkup(document); | 767 String body = createMarkup(document); |
| 768 | 768 |
| 769 httpBody = EncodedFormData::create( | 769 httpBody = EncodedFormData::create( |
| 770 UTF8Encoding().encode(body, WTF::EntitiesForUnencodables)); | 770 UTF8Encoding().encode(body, WTF::EntitiesForUnencodables)); |
| 771 } | 771 } |
| 772 | 772 |
| 773 createRequest(httpBody.release(), exceptionState); | 773 createRequest(std::move(httpBody), exceptionState); |
| 774 } | 774 } |
| 775 | 775 |
| 776 void XMLHttpRequest::send(const String& body, ExceptionState& exceptionState) { | 776 void XMLHttpRequest::send(const String& body, ExceptionState& exceptionState) { |
| 777 NETWORK_DVLOG(1) << this << " send() String " << body; | 777 NETWORK_DVLOG(1) << this << " send() String " << body; |
| 778 | 778 |
| 779 if (!initSend(exceptionState)) | 779 if (!initSend(exceptionState)) |
| 780 return; | 780 return; |
| 781 | 781 |
| 782 RefPtr<EncodedFormData> httpBody; | 782 RefPtr<EncodedFormData> httpBody; |
| 783 | 783 |
| 784 if (!body.isNull() && areMethodAndURLValidForSend()) { | 784 if (!body.isNull() && areMethodAndURLValidForSend()) { |
| 785 String contentType = getRequestHeader(HTTPNames::Content_Type); | 785 String contentType = getRequestHeader(HTTPNames::Content_Type); |
| 786 if (contentType.isEmpty()) { | 786 if (contentType.isEmpty()) { |
| 787 setRequestHeaderInternal(HTTPNames::Content_Type, | 787 setRequestHeaderInternal(HTTPNames::Content_Type, |
| 788 "text/plain;charset=UTF-8"); | 788 "text/plain;charset=UTF-8"); |
| 789 } else { | 789 } else { |
| 790 replaceCharsetInMediaType(contentType, "UTF-8"); | 790 replaceCharsetInMediaType(contentType, "UTF-8"); |
| 791 m_requestHeaders.set(HTTPNames::Content_Type, AtomicString(contentType)); | 791 m_requestHeaders.set(HTTPNames::Content_Type, AtomicString(contentType)); |
| 792 } | 792 } |
| 793 | 793 |
| 794 httpBody = EncodedFormData::create( | 794 httpBody = EncodedFormData::create( |
| 795 UTF8Encoding().encode(body, WTF::EntitiesForUnencodables)); | 795 UTF8Encoding().encode(body, WTF::EntitiesForUnencodables)); |
| 796 } | 796 } |
| 797 | 797 |
| 798 createRequest(httpBody.release(), exceptionState); | 798 createRequest(std::move(httpBody), exceptionState); |
| 799 } | 799 } |
| 800 | 800 |
| 801 void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState) { | 801 void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState) { |
| 802 NETWORK_DVLOG(1) << this << " send() Blob " << body->uuid(); | 802 NETWORK_DVLOG(1) << this << " send() Blob " << body->uuid(); |
| 803 | 803 |
| 804 if (!initSend(exceptionState)) | 804 if (!initSend(exceptionState)) |
| 805 return; | 805 return; |
| 806 | 806 |
| 807 RefPtr<EncodedFormData> httpBody; | 807 RefPtr<EncodedFormData> httpBody; |
| 808 | 808 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 823 httpBody->appendFile(file->path()); | 823 httpBody->appendFile(file->path()); |
| 824 else if (!file->fileSystemURL().isEmpty()) | 824 else if (!file->fileSystemURL().isEmpty()) |
| 825 httpBody->appendFileSystemURL(file->fileSystemURL()); | 825 httpBody->appendFileSystemURL(file->fileSystemURL()); |
| 826 else | 826 else |
| 827 NOTREACHED(); | 827 NOTREACHED(); |
| 828 } else { | 828 } else { |
| 829 httpBody->appendBlob(body->uuid(), body->blobDataHandle()); | 829 httpBody->appendBlob(body->uuid(), body->blobDataHandle()); |
| 830 } | 830 } |
| 831 } | 831 } |
| 832 | 832 |
| 833 createRequest(httpBody.release(), exceptionState); | 833 createRequest(std::move(httpBody), exceptionState); |
| 834 } | 834 } |
| 835 | 835 |
| 836 void XMLHttpRequest::send(FormData* body, ExceptionState& exceptionState) { | 836 void XMLHttpRequest::send(FormData* body, ExceptionState& exceptionState) { |
| 837 NETWORK_DVLOG(1) << this << " send() FormData " << body; | 837 NETWORK_DVLOG(1) << this << " send() FormData " << body; |
| 838 | 838 |
| 839 if (!initSend(exceptionState)) | 839 if (!initSend(exceptionState)) |
| 840 return; | 840 return; |
| 841 | 841 |
| 842 RefPtr<EncodedFormData> httpBody; | 842 RefPtr<EncodedFormData> httpBody; |
| 843 | 843 |
| 844 if (areMethodAndURLValidForSend()) { | 844 if (areMethodAndURLValidForSend()) { |
| 845 httpBody = body->encodeMultiPartFormData(); | 845 httpBody = body->encodeMultiPartFormData(); |
| 846 | 846 |
| 847 if (getRequestHeader(HTTPNames::Content_Type).isEmpty()) { | 847 if (getRequestHeader(HTTPNames::Content_Type).isEmpty()) { |
| 848 AtomicString contentType = | 848 AtomicString contentType = |
| 849 AtomicString("multipart/form-data; boundary=") + | 849 AtomicString("multipart/form-data; boundary=") + |
| 850 httpBody->boundary().data(); | 850 httpBody->boundary().data(); |
| 851 setRequestHeaderInternal(HTTPNames::Content_Type, contentType); | 851 setRequestHeaderInternal(HTTPNames::Content_Type, contentType); |
| 852 } | 852 } |
| 853 } | 853 } |
| 854 | 854 |
| 855 createRequest(httpBody.release(), exceptionState); | 855 createRequest(std::move(httpBody), exceptionState); |
| 856 } | 856 } |
| 857 | 857 |
| 858 void XMLHttpRequest::send(DOMArrayBuffer* body, | 858 void XMLHttpRequest::send(DOMArrayBuffer* body, |
| 859 ExceptionState& exceptionState) { | 859 ExceptionState& exceptionState) { |
| 860 NETWORK_DVLOG(1) << this << " send() ArrayBuffer " << body; | 860 NETWORK_DVLOG(1) << this << " send() ArrayBuffer " << body; |
| 861 | 861 |
| 862 sendBytesData(body->data(), body->byteLength(), exceptionState); | 862 sendBytesData(body->data(), body->byteLength(), exceptionState); |
| 863 } | 863 } |
| 864 | 864 |
| 865 void XMLHttpRequest::send(DOMArrayBufferView* body, | 865 void XMLHttpRequest::send(DOMArrayBufferView* body, |
| 866 ExceptionState& exceptionState) { | 866 ExceptionState& exceptionState) { |
| 867 NETWORK_DVLOG(1) << this << " send() ArrayBufferView " << body; | 867 NETWORK_DVLOG(1) << this << " send() ArrayBufferView " << body; |
| 868 | 868 |
| 869 sendBytesData(body->baseAddress(), body->byteLength(), exceptionState); | 869 sendBytesData(body->baseAddress(), body->byteLength(), exceptionState); |
| 870 } | 870 } |
| 871 | 871 |
| 872 void XMLHttpRequest::sendBytesData(const void* data, | 872 void XMLHttpRequest::sendBytesData(const void* data, |
| 873 size_t length, | 873 size_t length, |
| 874 ExceptionState& exceptionState) { | 874 ExceptionState& exceptionState) { |
| 875 if (!initSend(exceptionState)) | 875 if (!initSend(exceptionState)) |
| 876 return; | 876 return; |
| 877 | 877 |
| 878 RefPtr<EncodedFormData> httpBody; | 878 RefPtr<EncodedFormData> httpBody; |
| 879 | 879 |
| 880 if (areMethodAndURLValidForSend()) { | 880 if (areMethodAndURLValidForSend()) { |
| 881 httpBody = EncodedFormData::create(data, length); | 881 httpBody = EncodedFormData::create(data, length); |
| 882 } | 882 } |
| 883 | 883 |
| 884 createRequest(httpBody.release(), exceptionState); | 884 createRequest(std::move(httpBody), exceptionState); |
| 885 } | 885 } |
| 886 | 886 |
| 887 void XMLHttpRequest::sendForInspectorXHRReplay( | 887 void XMLHttpRequest::sendForInspectorXHRReplay( |
| 888 PassRefPtr<EncodedFormData> formData, | 888 PassRefPtr<EncodedFormData> formData, |
| 889 ExceptionState& exceptionState) { | 889 ExceptionState& exceptionState) { |
| 890 createRequest(formData ? formData->deepCopy() : nullptr, exceptionState); | 890 createRequest(formData ? formData->deepCopy() : nullptr, exceptionState); |
| 891 m_exceptionCode = exceptionState.code(); | 891 m_exceptionCode = exceptionState.code(); |
| 892 } | 892 } |
| 893 | 893 |
| 894 void XMLHttpRequest::throwForLoadFailureIfNeeded(ExceptionState& exceptionState, | 894 void XMLHttpRequest::throwForLoadFailureIfNeeded(ExceptionState& exceptionState, |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1843 visitor->traceWrappers(m_responseDocument); | 1843 visitor->traceWrappers(m_responseDocument); |
| 1844 visitor->traceWrappers(m_responseArrayBuffer); | 1844 visitor->traceWrappers(m_responseArrayBuffer); |
| 1845 XMLHttpRequestEventTarget::traceWrappers(visitor); | 1845 XMLHttpRequestEventTarget::traceWrappers(visitor); |
| 1846 } | 1846 } |
| 1847 | 1847 |
| 1848 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { | 1848 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { |
| 1849 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); | 1849 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); |
| 1850 } | 1850 } |
| 1851 | 1851 |
| 1852 } // namespace blink | 1852 } // namespace blink |
| OLD | NEW |