logo elektroda
logo elektroda
X
logo elektroda

ESP32 + PHP Server: No Content-Length in the server response header

dondu 477 6
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17945973
    dondu
    Moderator on vacation ...
    Hi.

    I have an account on cba.co.uk where I have placed a simple test script that generates a response in json format: http://test987.cba.pl/get_request2.php
    Code: PHP
    Log in, to see the code
    .
    After accessing the page and checking with Chroma's DevTools the header received back is missing the following parameter: Content-Length :

    ESP32 + PHP Server: No Content-Length in the server response header .

    For comparison using http://httpbin.org/get the server in the header corresponds with the parameter Content-Length :

    ESP32 + PHP Server: No Content-Length in the server response header .

    What could be the cause - I would like to know it before I write to cba.pl support.
    Or maybe I am making a mistake somewhere?

    Thank you in advance for your guidance :) .
  • ADVERTISEMENT
  • #2 17945981
    hindoos
    Level 35  
    This header is not necessary to receive the response from the server correctly, which is probably why it is omitted.
  • ADVERTISEMENT
  • #3 17945984
    dondu
    Moderator on vacation ...
    Unfortunately for me it is required - the original IDF of the ESP32 WiFi module requires it.
    When it is not present in the header it returns -1.
  • ADVERTISEMENT
  • Helpful post
    #4 17945989
    hindoos
    Level 35  
    Then write to support or try something like this:

    Code: PHP
    Log in, to see the code
    .
  • #5 17945991
    dondu
    Moderator on vacation ...
    I have tried but it is still not in the header :( .

    Edit:
    Sorry, I was trying to forcefully enter the value and not as you indicated.
    Now it works of course :D later I'll check if the ESP32 reads it correctly.


    I'll write to support anyway to enable this by default.

    Thank you for your quick help!
  • ADVERTISEMENT
  • #6 17946004
    hindoos
    Level 35  
    Just a point of clarification - I personally consider using functions such as ob_get_contents to be hacking the proper operation of the HTTP server and circumventing the problem ;) But I understand that since you are using cba.pl this is not a serious application and you can make such a concession to patch up an unusual server configuration :) .
  • #7 17946011
    dondu
    Moderator on vacation ...
    Yes for now for learning ESP32 the cba.pl server is enough :) .

    I checked the ESP32 - it read Content-Length correctly.

    Thanks again - have a nice day!
    Jacek

Topic summary

The discussion revolves around an issue with a PHP server hosted on cba.co.uk, where the response header is missing the Content-Length parameter, which is required by the ESP32 WiFi module. The user initially questioned the absence of this header and received responses indicating that it is not necessary for server responses. However, since the ESP32 requires it, a solution was proposed to calculate and set the Content-Length header using PHP's ob_get_contents() function. After some troubleshooting, the user confirmed that the solution worked, and the ESP32 correctly read the Content-Length value. The user plans to contact support to request that this header be enabled by default.
Summary generated by the language model.
ADVERTISEMENT