POST extra header fields

8 thoughts on “POST extra header fields

  1. Hi,

    I’m trying to send a POST with multiple extra header fields like the following:

    POST /webserver HTTP/1.0
    Host: server.com
    User-Agent: tesal
    Cache-Control: no-cache
    Pragma: no-cache
    X-DeviceId: P569ts
    X-DeviceType: tesal
    X-FirmwareNum: 2a
    Content-Type: text/plain
    Content-Length:15

    data = xxxxxxxx

    but HTTPSND command sends only one extra header fileds and the rest are sent as simple data.

    Any help would be appreciated.

    Regards, 

    Fahmi

      1. I’m sorry, I wrote my post a while after switching to another task so it wasn’t precise.

        The problem is: the server expects each header’s parameter in a new line, but the HTTPSND command consider all passed parameters in the <extra_header_line> field as a unique parameter.

        If I use the following command:

        AT#HTTPSND=0,0,"/webserver",90,1,"DeviceId:66666666"

        >>>vers=1
        data=<AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA>

        then the server will answer:

        HTTP/1.1 400 Bad Request
        Content-Length: 26
        Server: Microsoft-HTTPAPI/2.0
        Date: Fri, 18 Sep 2015 07:45:00 GMT
        Connection: close

        the device type is missing

        If I add the device ID like this:

        AT#HTTPSND=0,0,"/webserver",90,1,"DeviceId:66666666, DeviceType:tesal"

        >>>vers=1
        data=<AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA>

        OK

        #HTTPRING: 0,400,"",0

        I can see in Wireshark the following TCP stream

        POST /webserver HTTP/1.1
        Connection: close
        Host: test.com:80
        Authorization: Basic Og==
        Content-Type: text/plain; 1
        DeviceId:66666666, DeviceType:tesal
        Content-Length: 90

        HTTP/1.1 400 Bad Request
        Content-Length: 26
        Server: Microsoft-HTTPAPI/2.0
        Date: Fri, 18 Sep 2015 07:43:48 GMT
        Connection: close

        the device type is missingvers=1

        data=<AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA>

        You can see above that two POST parameters were presented at the same line (DeviceId:66666666, DeviceType:tesal).

        So I need a way to make each parameter in the POST be presented in a new line like the following:

        POST /webserver HTTP/1.0
        Host: server.com
        User-Agent: tesal
        Cache-Control: no-cache
        Pragma: no-cache
        DeviceId: P569ts
        DeviceType: tesal
        FirmwareNum: 2a
        Content-Type: text/plain
        Content-Length:15

        data = xxxxxxxx

        1. You can use a combination of two “greater than” (>>) characters to separate multiple headers inside the extra_header_lines.
          The module will replace “>>” with a CR-LF combination and it should be received correctly by the server.

          This command should work:

          AT#HTTPSND=0,0,”/webserver”,90,1,”DeviceId:66666666>>DeviceType:tesal”

          1. It didn’t make it.

            AT#HTTPSND=0,0,”/webserver”,90,1,”X-DeviceId:66666666>>X-DeviceType:tesal”

            >>>vers=1
            data=AAAAAAAA

            OK

            #HTTPRING: 0,400,””,0

            The server received however:

            POST /webserver HTTP/1.1
            Connection: close
            Host: server.com:80
            Authorization: Basic Og==
            Content-Type: text/plain; 1
            X-DeviceId:66666666>>X-DeviceType:tesal
            Content-Length: 90

            HTTP/1.1 400 Bad Request
            Content-Length: 26
            Server: Microsoft-HTTPAPI/2.0
            Date: Fri, 18 Sep 2015 12:42:24 GMT
            Connection: close

            the device type is missingvers=1

            data=AAAAAAAA

          2. 12.00.004

            The support for multiple header lines should have been added with SW version 12.00.xx5.
            I suggest you to upgrade the module to the latest SW version (12.00.006) and your issue should be solve.