Bug 188588 - [Curl] Don't send Content-Type header for POST request when body is null.
Summary: [Curl] Don't send Content-Type header for POST request when body is null.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Basuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-08-14 16:14 PDT by Basuke Suzuki
Modified: 2018-08-15 20:18 PDT (History)
8 users (show)

See Also:


Attachments
PATCH (2.73 KB, patch)
2018-08-14 16:30 PDT, Basuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Basuke Suzuki 2018-08-14 16:14:47 PDT
Caught by http/tests/xmlhttprequest/methods.html
Comment 1 Basuke Suzuki 2018-08-14 16:30:17 PDT
Created attachment 347126 [details]
PATCH
Comment 2 youenn fablet 2018-08-14 20:54:19 PDT
Comment on attachment 347126 [details]
PATCH

View in context: https://bugs.webkit.org/attachment.cgi?id=347126&action=review

> Source/WebCore/ChangeLog:9
> +        when body is null.

Is it done for CURL only for POST when setting CURLOPT_POST?
Is it also happening for other methods like PUT?

> Source/WebCore/platform/network/curl/CurlRequest.cpp:468
> +        m_curlHandle->removeRequestHeader("Content-Type"_s);

What happens if there are elementSize but no provided HTTPHeaderName::ContentType?
If it is the default CURL, does it align with other ports?
Comment 3 Basuke Suzuki 2018-08-15 11:23:16 PDT
Comment on attachment 347126 [details]
PATCH

View in context: https://bugs.webkit.org/attachment.cgi?id=347126&action=review

>> Source/WebCore/ChangeLog:9
>> +        when body is null.
> 
> Is it done for CURL only for POST when setting CURLOPT_POST?
> Is it also happening for other methods like PUT?

libcurl only behaves like this on POST. I guess POST is more popular use case for libcurl.

>> Source/WebCore/platform/network/curl/CurlRequest.cpp:468
>> +        m_curlHandle->removeRequestHeader("Content-Type"_s);
> 
> What happens if there are elementSize but no provided HTTPHeaderName::ContentType?
> If it is the default CURL, does it align with other ports?

That is covered by this case in the test:

    req.open("POST", "methods.cgi", false);
    req.send("");
    log('POST(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));

All three ports returns that content type is sent as "Content-Type: text/plain;charset=UTF-8".
Comment 4 Basuke Suzuki 2018-08-15 11:23:46 PDT
Comment on attachment 347126 [details]
PATCH

Thanks Youenn for r+
Comment 5 WebKit Commit Bot 2018-08-15 11:51:00 PDT
Comment on attachment 347126 [details]
PATCH

Clearing flags on attachment: 347126

Committed r234892: <https://trac.webkit.org/changeset/234892>
Comment 6 WebKit Commit Bot 2018-08-15 11:51:01 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2018-08-15 11:52:15 PDT
<rdar://problem/43343571>
Comment 8 Fujii Hironori 2018-08-15 13:46:34 PDT
http/tests/xmlhttprequest/methods.html is starting to fail.
https://build.webkit.org/builders/WinCairo%2064-bit%20WKL%20Release%20%28Tests%29/builds/1043
Comment 9 Basuke Suzuki 2018-08-15 20:18:14 PDT
I confirmed this difference. It is weird the result was different than at home. I'm double check my build env.