Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

HTTP Request with curl fails but why Firefox Developer Tools succeeds?



  • Hallo,

    I am trying to emulate a JavaScript XMLHttpRequest. On the Page I realized that the Web Interface is making a a POST Request to setjp

    387 : 6 <-- Value 6 is setting the option for percent reduction
    387 : 0 <-- Switching Option off

    The Header looks like:

    Host: 192.168.1.64
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0
    Accept: */*
    Accept-Language: de,en-US;q=0.7,en;q=0.3
    Accept-Encoding: gzip, deflate
    Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    X-Requested-With: XMLHttpRequest
    Content-Length: 469
    Origin: http://192.168.1.64
    Connection: keep-alive
    Referer: http://192.168.1.64/
    Cookie: banner_hidden=false
    

    The POST Data is:

    token=;preval=none;postval=110;{"302":{"0":"100","1":"60","2":"30","3":"0"},"303":{"0":"1","1":"2","2":"4","3":"8"},"306":"100","307":"0","382":"4","383":{"0":"100","1":"100","2":"100","3":"100","4":"100","5":"100","6":"100","7":"100","8":"100","9":"100","10":"100","11":"100"},"384":{"0":"0","1":"0","2":"0","3":"0","4":"0","5":"0","6":"0","7":"0","8":"0","9":"0","10":"0","11":"0"},"387":"6","401":"0","419":"60","420":"0","438":"0","491":"0","497":{"0":{"109":"1"}}}
    

    Now when I click on Edit and Resend and change the value of 387 then the request succeeds. 387 to 0 is switching off the option. 387 to 6 is setting the option to Percent

    But when I try to make the Request via curl it won't change anything.

    my bat file:

    curl.exe -d "token=;preval=none;postval=110;{\"302\":{\"0\":\"100\",\"1\":\"60\",\"2\":\"30\",\"3\":\"0\"},\"303\":{\"0\":\"1\",\"1\":\"2\",\"2\":\"4\",\"3\":\"8\"},\"306\":\"100\",\"307\":\"0\",\"382\":\"4\",\"383\": \"0\":\"100\",\"1\":\"100\",\"2\":\"100\",\"3\":\"100\",\"4\":\"100\",\"5\":\"100\",\"6\":\"100\",\"7\":\"100\",\"8\":\"100\",\"9\":\"100\",\"10\":\"100\",\"11\":\"100\"},\"384\":{\"0\":\"0\",\"1\":\"0\",\"2\":\"0\",\"3\":\"0\",\"4\":\"0\",\"5\":\"0\",\"6\":\"0\",\"7\":\"0\",\"8\":\"0\",\"9\":\"0\",\"10\":\"0\",\"11\":\"0\"}, \"387\":\"0\", \"401\":\"0\",\"419\":\"70\",\"420\":\"0\",\"438\":\"0\",\"491\":\"0\",\"497\":{\"0\":{\"109\":\"1\"}}}"^
     -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0"^
     -H "Accept: */*"^
     -H "Accept-Language: de,en-US;q=0.7,en;q=0.3"^
     -H "Accept-Encoding: gzip, deflate"^
     -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"^
     -H "X-Requested-With: XMLHttpRequest"^
     -H "Content-Length: 469"^
     -H "Origin: http://192.168.1.64"^
     -H "Connection: keep-alive"^
     -H "Referer: http://192.168.1.64/"^
     -H "Cookie: banner_hidden=false"^
     --http1.1^
     -X POST http://192.168.1.64/setjp
    

    Any Idea why the curl request is not doing the same as the Firefox Request?

    If I write HTTP Requests I am usually trying it with CURL before using Qt for requests.


Log in to reply