XHR/POST form-data: lower-case Content-Type

Not reproducible Issue #12174370

Details

Author
Peter H.
Created
May 30, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
15.15063
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

An XHR is used to send a file via POST:

  • Use FormData.append in order to add form name and file name to blob data
  • Add Authorization header to request
  • Send request

On PC (Win 14393) “Content-Type” will be transmitted with capital "C".
On Phone (Win 15063) “content-Type” will be transmitted with lower-case "c". The web server will answer "400 Bad Request".

Trying to manually add Content-Type will cause Edge to remove the “boundary” parameter from the request.

Attachments

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “James M.”

  • Hello,

    Thank you for providing this information about the issue. Unfortunately, we are unable to reproduce this problem in Edge with the information at hand. Please update this case when you can provide more details, such as a sample website and repro steps.

    Best Wishes,
    The MS Edge Team

  • Microsoft Edge Team

    Changed Status to “Not reproducible”

  • Changed Status from “Not reproducible”

  • Dear James,

    Since the Creators update which took Edge on my to version 15063, I am having the same problem now also on the PC.

    The interesting thing is that it does not happen if using the browser directly. I have created the following html test page:

    OK

    The request will be sent correctly with CAPTIAL Content-Type:
    POST /cgi-bin/hi3510/upgrade.cgi HTTP/1.1
    Accept: text/html, application/xhtml+xml, image/jxr, /
    Accept-Language: de-DE,de;q=0.8,it-IT;q=0.7,it;q=0.5,en-US;q=0.3,en;q=0.2
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063
    Content-Type: multipart/form-data; boundary=---------------------------7e13c1fa0eb6
    Accept-Encoding: gzip, deflate
    Host: 192.168.25.170
    Content-Length: 6382331
    Connection: Keep-Alive
    Cache-Control: no-cache
    Authorization: Basic YWRtaW46YWRtaW4=
    Content-Disposition: form-data; name="setting_file"; filename="B18WL_V7.1.9.1.1-20170308 BV-A 1.8.pkg"
    Content-Type: application/x-zip-compressed

    If I use the following code in JS:
    function send_fw(blob)
    {
    var header, url;
    var xmlHttp = new XMLHttpRequest();
    var fd = new FormData();

    fd.append("setting_file", blob, ufile);
    
    xmlHttp.onreadystatechange = function ()
    {
        if (xmlHttp.readyState === 4)
        {
            if (xmlHttp.status === 200)
            {
                update_result(xmlHttp.responseText);
            }
            else
            {
                update_result(xmlHttp.status + " " + xmlHttp.responseText);
            }
        }
    };
    
    url = "http://" + mycam_ip + "/cgi-bin/hi3510/upgrade.cgi";
    xmlHttp.open("POST", url, true);
    header = "Basic " + b64enc("admin:" + mycam_pw);
    xmlHttp.setRequestHeader("Authorization", header);
    xmlHttp.timeout = 25000;
    xmlHttp.ontimeout = function ()
    xmlHttp.send(fd);
    

    }

    The request will be sent with small Content-Type and it fails with BAD REQUEST:
    POST /cgi-bin/hi3510/upgrade.cgi HTTP/1.1
    Accept: /
    Accept-Language: de-DE,de;q=0.8,it-IT;q=0.7,it;q=0.5,en-US;q=0.3,en;q=0.2
    Authorization: Basic YWRtaW46YWRtaW4=
    content-type: multipart/form-data; boundary=---------------------------7e1fb2ea0f0e
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; MSAppHost/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063
    Host: 192.168.25.170
    Content-Length: 6366442
    Connection: Keep-Alive
    Cache-Control: no-cache
    Content-Disposition: form-data; name="setting_file"; filename="B18WL_V7.1.9.1.1-20170628.pkg"
    Content-Type: application/octet-stream

    What has happened in that update? If this is not a bug, what can I do to get a compliant behaviro for the XHR as well?

    Regards
    Peter

  • For some reason there is “OK” where I put the HTML sample code. I try again:

    OK

  • //
    //
    //
    //

    //

    //
    //
    //
    //OK

    //

    //

    //

  • No way to get the HTML shown here, I uploaded the HTML sample as attachment test.htm. :-)

  • Microsoft Edge Team

    Changed Assigned To to “James M.”

  • Hello,

    Thank you for the additional information about the issue. Unfortunately, your demo contains a form action which is not resolving. Can you describe the repro steps to be sure we are using the attachment correctly?

    Best Wishes,
    The MS Edge Team
     

  • Microsoft Edge Team

    Changed Status to “Not reproducible”

You need to sign in to your Microsoft account to add a comment.

Sign in