Changeset 192680 in webkit


Ignore:
Timestamp:
Nov 20, 2015, 1:25:56 AM (10 years ago)
Author:
youenn.fablet@crf.canon.fr
Message:

Use HTTPHeaderName as much as possible in XMLHttpRequest
https://bugs.webkit.org/show_bug.cgi?id=151438

Reviewed by Darin Adler.

Removing XMLHttpRequest::setRequestHeaderInternal and XMLHttpRequest::getRequestHeader.
Using directly HTTPHeaderMap.add, HTTPHeaderMap.set and HTTPHeaderMap.get.

No change in behavior.

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::send):
(WebCore::XMLHttpRequest::setRequestHeader):
(WebCore::XMLHttpRequest::getAllResponseHeaders):

  • xml/XMLHttpRequest.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r192679 r192680  
     12015-11-20  Youenn Fablet  <youenn.fablet@crf.canon.fr>
     2
     3        Use HTTPHeaderName as much as possible in XMLHttpRequest
     4        https://bugs.webkit.org/show_bug.cgi?id=151438
     5
     6        Reviewed by Darin Adler.
     7
     8        Removing XMLHttpRequest::setRequestHeaderInternal and XMLHttpRequest::getRequestHeader.
     9        Using directly HTTPHeaderMap.add, HTTPHeaderMap.set and HTTPHeaderMap.get.
     10
     11        No change in behavior.
     12
     13        * xml/XMLHttpRequest.cpp:
     14        (WebCore::XMLHttpRequest::send):
     15        (WebCore::XMLHttpRequest::setRequestHeader):
     16        (WebCore::XMLHttpRequest::getAllResponseHeaders):
     17        * xml/XMLHttpRequest.h:
     18
    1192015-11-20  Eric Carlson  <eric.carlson@apple.com>
    220
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r192620 r192680  
    596596#if ENABLE(DASHBOARD_SUPPORT)
    597597            if (usesDashboardBackwardCompatibilityMode())
    598                 setRequestHeaderInternal("Content-Type", "application/x-www-form-urlencoded");
     598                m_requestHeaders.set(HTTPHeaderName::ContentType, ASCIILiteral("application/x-www-form-urlencoded"));
    599599            else
    600600#endif
    601601                // FIXME: this should include the charset used for encoding.
    602                 setRequestHeaderInternal("Content-Type", document->isHTMLDocument() ? "text/html;charset=UTF-8":"application/xml;charset=UTF-8");
     602                m_requestHeaders.set(HTTPHeaderName::ContentType, document->isHTMLDocument() ? ASCIILiteral("text/html;charset=UTF-8") : ASCIILiteral("application/xml;charset=UTF-8"));
    603603        }
    604604
     
    621621
    622622    if (!body.isNull() && m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
    623         String contentType = getRequestHeader("Content-Type");
     623        String contentType = m_requestHeaders.get(HTTPHeaderName::ContentType);
    624624        if (contentType.isNull()) {
    625625#if ENABLE(DASHBOARD_SUPPORT)
    626626            if (usesDashboardBackwardCompatibilityMode())
    627                 setRequestHeaderInternal("Content-Type", "application/x-www-form-urlencoded");
     627                m_requestHeaders.set(HTTPHeaderName::ContentType, ASCIILiteral("application/x-www-form-urlencoded"));
    628628            else
    629629#endif
    630                 setRequestHeaderInternal("Content-Type", "text/plain;charset=UTF-8");
     630                m_requestHeaders.set(HTTPHeaderName::ContentType, ASCIILiteral("text/plain;charset=UTF-8"));
    631631        } else {
    632632            replaceCharsetInMediaType(contentType, "UTF-8");
     
    651651            const String& blobType = body->type();
    652652            if (!blobType.isEmpty() && isValidContentType(blobType))
    653                 setRequestHeaderInternal("Content-Type", blobType);
     653                m_requestHeaders.set(HTTPHeaderName::ContentType, blobType);
    654654            else {
    655655                // From FileAPI spec, whenever media type cannot be determined, empty string must be returned.
    656                 setRequestHeaderInternal("Content-Type", "");
     656                m_requestHeaders.set(HTTPHeaderName::ContentType, emptyString());
    657657            }
    658658        }
     
    676676
    677677        if (!m_requestHeaders.contains(HTTPHeaderName::ContentType))
    678             setRequestHeaderInternal("Content-Type", makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data()));
     678            m_requestHeaders.set(HTTPHeaderName::ContentType, makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data()));
    679679    }
    680680
     
    956956    }
    957957
    958     setRequestHeaderInternal(name, normalizedValue);
    959 }
    960 
    961 void XMLHttpRequest::setRequestHeaderInternal(const String& name, const String& value)
    962 {
    963     m_requestHeaders.add(name, value);
    964 }
    965 
    966 String XMLHttpRequest::getRequestHeader(const String& name) const
    967 {
    968     return m_requestHeaders.get(name);
     958    m_requestHeaders.add(name, normalizedValue);
    969959}
    970960
  • trunk/Source/WebCore/xml/XMLHttpRequest.h

    r192361 r192680  
    177177    void sendBytesData(const void*, size_t, ExceptionCode&);
    178178
    179     String getRequestHeader(const String& name) const;
    180     void setRequestHeaderInternal(const String& name, const String& value);
    181 
    182179    void changeState(State newState);
    183180    void callReadyStateChangeListener();
Note: See TracChangeset for help on using the changeset viewer.