Changeset 246143 in webkit


Ignore:
Timestamp:
Jun 5, 2019 8:55:13 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[Curl] Report all request headers to web inspector.
https://bugs.webkit.org/show_bug.cgi?id=191653

Patch by Takashi Komori <Takashi.Komori@sony.com> on 2019-06-05
Reviewed by Fujii Hironori.

Source/WebCore:

Test: http/tests/inspector/network/resource-request-headers.html

  • platform/network/curl/CurlContext.cpp:

(WebCore::CurlHandle::setDebugCallbackFunction):

  • platform/network/curl/CurlContext.h:
  • platform/network/curl/CurlRequest.cpp:

(WebCore::CurlRequest::setupTransfer):
(WebCore::CurlRequest::didReceiveDebugInfo):
(WebCore::CurlRequest::updateNetworkLoadMetrics):
(WebCore::CurlRequest::didReceiveDebugInfoCallback):

  • platform/network/curl/CurlRequest.h:

LayoutTests:

  • platform/wincairo/TestExpectations:
  • platform/wincairo/http/tests/inspector/network/resource-request-headers-expected.txt: Added.
Location:
trunk
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r246138 r246143  
     12019-06-05  Takashi Komori  <Takashi.Komori@sony.com>
     2
     3        [Curl] Report all request headers to web inspector.
     4        https://bugs.webkit.org/show_bug.cgi?id=191653
     5
     6        Reviewed by Fujii Hironori.
     7
     8        * platform/wincairo/TestExpectations:
     9        * platform/wincairo/http/tests/inspector/network/resource-request-headers-expected.txt: Added.
     10
    1112019-06-05  Myles C. Maxfield  <mmaxfield@apple.com>
    212
  • trunk/LayoutTests/platform/wincairo/TestExpectations

    r246076 r246143  
    892892http/tests/images [ Skip ]
    893893http/tests/incremental [ Skip ]
     894
    894895http/tests/inspector [ Skip ]
     896http/tests/inspector/network/resource-request-headers.html [ Pass ]
     897
    895898http/tests/loading [ Skip ]
    896899http/tests/local/blob [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r246142 r246143  
     12019-06-05  Takashi Komori  <Takashi.Komori@sony.com>
     2
     3        [Curl] Report all request headers to web inspector.
     4        https://bugs.webkit.org/show_bug.cgi?id=191653
     5
     6        Reviewed by Fujii Hironori.
     7
     8        Test: http/tests/inspector/network/resource-request-headers.html
     9
     10        * platform/network/curl/CurlContext.cpp:
     11        (WebCore::CurlHandle::setDebugCallbackFunction):
     12        * platform/network/curl/CurlContext.h:
     13        * platform/network/curl/CurlRequest.cpp:
     14        (WebCore::CurlRequest::setupTransfer):
     15        (WebCore::CurlRequest::didReceiveDebugInfo):
     16        (WebCore::CurlRequest::updateNetworkLoadMetrics):
     17        (WebCore::CurlRequest::didReceiveDebugInfoCallback):
     18        * platform/network/curl/CurlRequest.h:
     19
    1202019-06-05  Said Abou-Hallawa  <sabouhallawa@apple.com>
    221
  • trunk/Source/WebCore/platform/network/curl/CurlContext.cpp

    r243654 r246143  
    639639}
    640640
     641void CurlHandle::setDebugCallbackFunction(curl_debug_callback callbackFunc, void* userData)
     642{
     643    curl_easy_setopt(m_handle, CURLOPT_DEBUGFUNCTION, callbackFunc);
     644    curl_easy_setopt(m_handle, CURLOPT_DEBUGDATA, userData);
     645    curl_easy_setopt(m_handle, CURLOPT_VERBOSE, 1L);
     646}
     647
    641648void CurlHandle::enableConnectionOnly()
    642649{
  • trunk/Source/WebCore/platform/network/curl/CurlContext.h

    r243654 r246143  
    274274    void setReadCallbackFunction(curl_read_callback, void*);
    275275    void setSslCtxCallbackFunction(curl_ssl_ctx_callback, void*);
     276    void setDebugCallbackFunction(curl_debug_callback, void*);
    276277
    277278    // Status
  • trunk/Source/WebCore/platform/network/curl/CurlRequest.cpp

    r244684 r246143  
    235235    m_curlHandle->setWriteCallbackFunction(didReceiveDataCallback, this);
    236236
     237    if (m_captureExtraMetrics)
     238        m_curlHandle->setDebugCallbackFunction(didReceiveDebugInfoCallback, this);
     239
    237240    m_curlHandle->setTimeout(timeoutInterval());
    238241
     
    490493    m_multipartHandle = nullptr;
    491494    m_curlHandle = nullptr;
     495}
     496
     497int CurlRequest::didReceiveDebugInfo(curl_infotype type, char* data, size_t size)
     498{
     499    if (!data)
     500        return 0;
     501
     502    if (type == CURLINFO_HEADER_OUT) {
     503        String requestHeader(data, size);
     504        auto headerFields = requestHeader.split("\r\n");
     505        // Remove the request line
     506        if (headerFields.size())
     507            headerFields.remove(0);
     508
     509        for (auto& header : headerFields) {
     510            auto pos = header.find(":");
     511            if (pos != notFound) {
     512                auto key = header.left(pos).stripWhiteSpace();
     513                auto value = header.substring(pos + 1).stripWhiteSpace();
     514                m_requestHeaders.add(key, value);
     515            }
     516        }
     517    }
     518
     519    return 0;
    492520}
    493521
     
    697725        if (m_captureExtraMetrics) {
    698726            m_curlHandle->addExtraNetworkLoadMetrics(m_networkLoadMetrics);
    699             m_networkLoadMetrics.requestHeaders = m_request.httpHeaderFields();
     727            m_networkLoadMetrics.requestHeaders = m_requestHeaders;
    700728            m_networkLoadMetrics.responseBodyDecodedSize = m_totalReceivedSize;
    701729        }
     
    767795}
    768796
     797int CurlRequest::didReceiveDebugInfoCallback(CURL*, curl_infotype type, char* data, size_t size, void* userData)
     798{
     799    return static_cast<CurlRequest*>(userData)->didReceiveDebugInfo(type, data, size);
     800}
     801
    769802}
    770803
  • trunk/Source/WebCore/platform/network/curl/CurlRequest.h

    r245215 r246143  
    135135    void invokeCancel();
    136136
     137    int didReceiveDebugInfo(curl_infotype, char*, size_t);
     138
    137139    // For setup
    138140    void appendAcceptLanguageHeader(HTTPHeaderMap&);
     
    164166    static size_t didReceiveHeaderCallback(char*, size_t, size_t, void*);
    165167    static size_t didReceiveDataCallback(char*, size_t, size_t, void*);
     168    static int didReceiveDebugInfoCallback(CURL*, curl_infotype, char*, size_t, void*);
    166169
    167170
     
    212215    bool m_captureExtraMetrics;
    213216    NetworkLoadMetrics m_networkLoadMetrics;
     217    HTTPHeaderMap m_requestHeaders;
    214218    MonotonicTime m_requestStartTime { MonotonicTime::nan() };
    215219    MonotonicTime m_performStartTime;
Note: See TracChangeset for help on using the changeset viewer.