| 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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState) | 633 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState) |
| 634 { | 634 { |
| 635 WTF_LOG(Network, "XMLHttpRequest %p send() Document %p", this, document); | 635 WTF_LOG(Network, "XMLHttpRequest %p send() Document %p", this, document); |
| 636 | 636 |
| 637 ASSERT(document); | 637 ASSERT(document); |
| 638 | 638 |
| 639 if (!initSend(exceptionState)) | 639 if (!initSend(exceptionState)) |
| 640 return; | 640 return; |
| 641 | 641 |
| 642 if (areMethodAndURLValidForSend()) { | 642 if (areMethodAndURLValidForSend()) { |
| 643 String contentType = getRequestHeader("Content-Type"); | 643 if (getRequestHeader("Content-Type").isEmpty()) { |
| 644 if (contentType.isEmpty()) { | |
| 645 // FIXME: this should include the charset used for encoding. | 644 // FIXME: this should include the charset used for encoding. |
| 646 setRequestHeaderInternal("Content-Type", "application/xml"); | 645 setRequestHeaderInternal("Content-Type", "application/xml"); |
| 647 } | 646 } |
| 648 | 647 |
| 649 // FIXME: According to XMLHttpRequest Level 2, this should use the Docum
ent.innerHTML algorithm | 648 // FIXME: According to XMLHttpRequest Level 2, this should use the Docum
ent.innerHTML algorithm |
| 650 // from the HTML5 specification to serialize the document. | 649 // from the HTML5 specification to serialize the document. |
| 651 String body = createMarkup(document); | 650 String body = createMarkup(document); |
| 652 | 651 |
| 653 // FIXME: This should use value of document.inputEncoding to determine t
he encoding to use. | 652 // FIXME: This should use value of document.inputEncoding to determine t
he encoding to use. |
| 654 m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, WTF::
EntitiesForUnencodables)); | 653 m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, WTF::
EntitiesForUnencodables)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 684 } | 683 } |
| 685 | 684 |
| 686 void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState) | 685 void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState) |
| 687 { | 686 { |
| 688 WTF_LOG(Network, "XMLHttpRequest %p send() Blob '%s'", this, body->uuid().ut
f8().data()); | 687 WTF_LOG(Network, "XMLHttpRequest %p send() Blob '%s'", this, body->uuid().ut
f8().data()); |
| 689 | 688 |
| 690 if (!initSend(exceptionState)) | 689 if (!initSend(exceptionState)) |
| 691 return; | 690 return; |
| 692 | 691 |
| 693 if (areMethodAndURLValidForSend()) { | 692 if (areMethodAndURLValidForSend()) { |
| 694 const String& contentType = getRequestHeader("Content-Type"); | 693 if (getRequestHeader("Content-Type").isEmpty()) { |
| 695 if (contentType.isEmpty()) { | |
| 696 const String& blobType = body->type(); | 694 const String& blobType = body->type(); |
| 697 if (!blobType.isEmpty() && isValidContentType(blobType)) | 695 if (!blobType.isEmpty() && isValidContentType(blobType)) |
| 698 setRequestHeaderInternal("Content-Type", AtomicString(blobType))
; | 696 setRequestHeaderInternal("Content-Type", AtomicString(blobType))
; |
| 699 else { | 697 else { |
| 700 // From FileAPI spec, whenever media type cannot be determined,
empty string must be returned. | 698 // From FileAPI spec, whenever media type cannot be determined,
empty string must be returned. |
| 701 setRequestHeaderInternal("Content-Type", ""); | 699 setRequestHeaderInternal("Content-Type", ""); |
| 702 } | 700 } |
| 703 } | 701 } |
| 704 | 702 |
| 705 // FIXME: add support for uploading bundles. | 703 // FIXME: add support for uploading bundles. |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 setRequestHeaderInternal(name, value); | 1103 setRequestHeaderInternal(name, value); |
| 1106 } | 1104 } |
| 1107 | 1105 |
| 1108 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const At
omicString& value) | 1106 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const At
omicString& value) |
| 1109 { | 1107 { |
| 1110 HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value); | 1108 HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value); |
| 1111 if (!result.isNewEntry) | 1109 if (!result.isNewEntry) |
| 1112 result.iterator->value = result.iterator->value + ", " + value; | 1110 result.iterator->value = result.iterator->value + ", " + value; |
| 1113 } | 1111 } |
| 1114 | 1112 |
| 1115 AtomicString XMLHttpRequest::getRequestHeader(const AtomicString& name) const | 1113 const AtomicString& XMLHttpRequest::getRequestHeader(const AtomicString& name) c
onst |
| 1116 { | 1114 { |
| 1117 return m_requestHeaders.get(name); | 1115 return m_requestHeaders.get(name); |
| 1118 } | 1116 } |
| 1119 | 1117 |
| 1120 String XMLHttpRequest::getAllResponseHeaders(ExceptionState& exceptionState) con
st | 1118 String XMLHttpRequest::getAllResponseHeaders(ExceptionState& exceptionState) con
st |
| 1121 { | 1119 { |
| 1122 if (m_state < HEADERS_RECEIVED || m_error) | 1120 if (m_state < HEADERS_RECEIVED || m_error) |
| 1123 return ""; | 1121 return ""; |
| 1124 | 1122 |
| 1125 StringBuilder stringBuilder; | 1123 StringBuilder stringBuilder; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1144 stringBuilder.append(':'); | 1142 stringBuilder.append(':'); |
| 1145 stringBuilder.append(' '); | 1143 stringBuilder.append(' '); |
| 1146 stringBuilder.append(it->value); | 1144 stringBuilder.append(it->value); |
| 1147 stringBuilder.append('\r'); | 1145 stringBuilder.append('\r'); |
| 1148 stringBuilder.append('\n'); | 1146 stringBuilder.append('\n'); |
| 1149 } | 1147 } |
| 1150 | 1148 |
| 1151 return stringBuilder.toString(); | 1149 return stringBuilder.toString(); |
| 1152 } | 1150 } |
| 1153 | 1151 |
| 1154 AtomicString XMLHttpRequest::getResponseHeader(const AtomicString& name, Excepti
onState& exceptionState) const | 1152 const AtomicString& XMLHttpRequest::getResponseHeader(const AtomicString& name,
ExceptionState& exceptionState) const |
| 1155 { | 1153 { |
| 1156 if (m_state < HEADERS_RECEIVED || m_error) | 1154 if (m_state < HEADERS_RECEIVED || m_error) |
| 1157 return nullAtom; | 1155 return nullAtom; |
| 1158 | 1156 |
| 1159 // See comment in getAllResponseHeaders above. | 1157 // See comment in getAllResponseHeaders above. |
| 1160 if (isSetCookieHeader(name) && !securityOrigin()->canLoadLocalResources()) { | 1158 if (isSetCookieHeader(name) && !securityOrigin()->canLoadLocalResources()) { |
| 1161 logConsoleError(executionContext(), "Refused to get unsafe header \"" +
name + "\""); | 1159 logConsoleError(executionContext(), "Refused to get unsafe header \"" +
name + "\""); |
| 1162 return nullAtom; | 1160 return nullAtom; |
| 1163 } | 1161 } |
| 1164 | 1162 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 { | 1426 { |
| 1429 return EventTargetNames::XMLHttpRequest; | 1427 return EventTargetNames::XMLHttpRequest; |
| 1430 } | 1428 } |
| 1431 | 1429 |
| 1432 ExecutionContext* XMLHttpRequest::executionContext() const | 1430 ExecutionContext* XMLHttpRequest::executionContext() const |
| 1433 { | 1431 { |
| 1434 return ActiveDOMObject::executionContext(); | 1432 return ActiveDOMObject::executionContext(); |
| 1435 } | 1433 } |
| 1436 | 1434 |
| 1437 } // namespace WebCore | 1435 } // namespace WebCore |
| OLD | NEW |