Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: Source/core/xml/XMLHttpRequest.cpp

Issue 102103002: Have HashMap<KeyType, AtomicString>::get() return a const reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState) 618 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState)
619 { 619 {
620 WTF_LOG(Network, "XMLHttpRequest %p send() Document %p", this, document); 620 WTF_LOG(Network, "XMLHttpRequest %p send() Document %p", this, document);
621 621
622 ASSERT(document); 622 ASSERT(document);
623 623
624 if (!initSend(exceptionState)) 624 if (!initSend(exceptionState))
625 return; 625 return;
626 626
627 if (areMethodAndURLValidForSend()) { 627 if (areMethodAndURLValidForSend()) {
628 String contentType = getRequestHeader("Content-Type"); 628 if (getRequestHeader("Content-Type").isEmpty()) {
629 if (contentType.isEmpty()) {
630 // FIXME: this should include the charset used for encoding. 629 // FIXME: this should include the charset used for encoding.
631 setRequestHeaderInternal("Content-Type", "application/xml"); 630 setRequestHeaderInternal("Content-Type", "application/xml");
632 } 631 }
633 632
634 // FIXME: According to XMLHttpRequest Level 2, this should use the Docum ent.innerHTML algorithm 633 // FIXME: According to XMLHttpRequest Level 2, this should use the Docum ent.innerHTML algorithm
635 // from the HTML5 specification to serialize the document. 634 // from the HTML5 specification to serialize the document.
636 String body = createMarkup(document); 635 String body = createMarkup(document);
637 636
638 // FIXME: This should use value of document.inputEncoding to determine t he encoding to use. 637 // FIXME: This should use value of document.inputEncoding to determine t he encoding to use.
639 m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, WTF:: EntitiesForUnencodables)); 638 m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, WTF:: EntitiesForUnencodables));
(...skipping 29 matching lines...) Expand all
669 } 668 }
670 669
671 void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState) 670 void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState)
672 { 671 {
673 WTF_LOG(Network, "XMLHttpRequest %p send() Blob '%s'", this, body->uuid().ut f8().data()); 672 WTF_LOG(Network, "XMLHttpRequest %p send() Blob '%s'", this, body->uuid().ut f8().data());
674 673
675 if (!initSend(exceptionState)) 674 if (!initSend(exceptionState))
676 return; 675 return;
677 676
678 if (areMethodAndURLValidForSend()) { 677 if (areMethodAndURLValidForSend()) {
679 const String& contentType = getRequestHeader("Content-Type"); 678 if (getRequestHeader("Content-Type").isEmpty()) {
680 if (contentType.isEmpty()) {
681 const String& blobType = body->type(); 679 const String& blobType = body->type();
682 if (!blobType.isEmpty() && isValidContentType(blobType)) 680 if (!blobType.isEmpty() && isValidContentType(blobType))
683 setRequestHeaderInternal("Content-Type", AtomicString(blobType)) ; 681 setRequestHeaderInternal("Content-Type", AtomicString(blobType)) ;
684 else { 682 else {
685 // From FileAPI spec, whenever media type cannot be determined, empty string must be returned. 683 // From FileAPI spec, whenever media type cannot be determined, empty string must be returned.
686 setRequestHeaderInternal("Content-Type", ""); 684 setRequestHeaderInternal("Content-Type", "");
687 } 685 }
688 } 686 }
689 687
690 // FIXME: add support for uploading bundles. 688 // FIXME: add support for uploading bundles.
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 setRequestHeaderInternal(name, value); 1076 setRequestHeaderInternal(name, value);
1079 } 1077 }
1080 1078
1081 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const At omicString& value) 1079 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const At omicString& value)
1082 { 1080 {
1083 HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value); 1081 HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value);
1084 if (!result.isNewEntry) 1082 if (!result.isNewEntry)
1085 result.iterator->value = result.iterator->value + ", " + value; 1083 result.iterator->value = result.iterator->value + ", " + value;
1086 } 1084 }
1087 1085
1088 AtomicString XMLHttpRequest::getRequestHeader(const AtomicString& name) const 1086 const AtomicString& XMLHttpRequest::getRequestHeader(const AtomicString& name) c onst
1089 { 1087 {
1090 return m_requestHeaders.get(name); 1088 return m_requestHeaders.get(name);
1091 } 1089 }
1092 1090
1093 String XMLHttpRequest::getAllResponseHeaders(ExceptionState& exceptionState) con st 1091 String XMLHttpRequest::getAllResponseHeaders(ExceptionState& exceptionState) con st
1094 { 1092 {
1095 if (m_state < HEADERS_RECEIVED || m_error) 1093 if (m_state < HEADERS_RECEIVED || m_error)
1096 return ""; 1094 return "";
1097 1095
1098 StringBuilder stringBuilder; 1096 StringBuilder stringBuilder;
(...skipping 18 matching lines...) Expand all
1117 stringBuilder.append(':'); 1115 stringBuilder.append(':');
1118 stringBuilder.append(' '); 1116 stringBuilder.append(' ');
1119 stringBuilder.append(it->value); 1117 stringBuilder.append(it->value);
1120 stringBuilder.append('\r'); 1118 stringBuilder.append('\r');
1121 stringBuilder.append('\n'); 1119 stringBuilder.append('\n');
1122 } 1120 }
1123 1121
1124 return stringBuilder.toString(); 1122 return stringBuilder.toString();
1125 } 1123 }
1126 1124
1127 AtomicString XMLHttpRequest::getResponseHeader(const AtomicString& name, Excepti onState& exceptionState) const 1125 const AtomicString& XMLHttpRequest::getResponseHeader(const AtomicString& name, ExceptionState& exceptionState) const
1128 { 1126 {
1129 if (m_state < HEADERS_RECEIVED || m_error) 1127 if (m_state < HEADERS_RECEIVED || m_error)
1130 return nullAtom; 1128 return nullAtom;
1131 1129
1132 // See comment in getAllResponseHeaders above. 1130 // See comment in getAllResponseHeaders above.
1133 if (isSetCookieHeader(name) && !securityOrigin()->canLoadLocalResources()) { 1131 if (isSetCookieHeader(name) && !securityOrigin()->canLoadLocalResources()) {
1134 logConsoleError(executionContext(), "Refused to get unsafe header \"" + name + "\""); 1132 logConsoleError(executionContext(), "Refused to get unsafe header \"" + name + "\"");
1135 return nullAtom; 1133 return nullAtom;
1136 } 1134 }
1137 1135
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 { 1391 {
1394 return EventTargetNames::XMLHttpRequest; 1392 return EventTargetNames::XMLHttpRequest;
1395 } 1393 }
1396 1394
1397 ExecutionContext* XMLHttpRequest::executionContext() const 1395 ExecutionContext* XMLHttpRequest::executionContext() const
1398 { 1396 {
1399 return ActiveDOMObject::executionContext(); 1397 return ActiveDOMObject::executionContext();
1400 } 1398 }
1401 1399
1402 } // namespace WebCore 1400 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698