Shubham Kulkarni 0a395134d4 Split example_tests with Example_WIFI tag group into Example_OTA and Example_Protocols 4 سال پیش
..
main 94512a76b7 example/http_server: add basic authenticated example to HTTP server 5 سال پیش
CMakeLists.txt 500c247030 protocol examples: enable protocol examples for esp32sbeta 6 سال پیش
Makefile 66fb5a29bb Whitespace: Automated whitespace fixes (large commit) 5 سال پیش
README.md 03901946ba Explain how to fix 'httpd_parse: header too long' 4 سال پیش
http_server_simple_test.py 0a395134d4 Split example_tests with Example_WIFI tag group into Example_OTA and Example_Protocols 4 سال پیش
sdkconfig.ci fc7b962e54 bugfix: fix http_server example sdkconfig file name 4 سال پیش

README.md

Simple HTTPD Server Example

The Example consists of HTTPD server demo with demostration of URI handling :

1. URI \hello for GET command returns "Hello World!" message
2. URI \echo for POST command echoes back the POSTed message
  • Open the project configuration menu (idf.py menuconfig) to configure Wi-Fi or Ethernet. See "Establishing Wi-Fi or Ethernet Connection" section in examples/protocols/README.md for more details.

  • In order to test the HTTPD server persistent sockets demo :

    1. compile and burn the firmware idf.py -p PORT flash
    2. run idf.py -p PORT monitor and note down the IP assigned to your ESP module. The default port is 80
    3. test the example :
      • run the test script : "python scripts/client.py <IP> <port> <MSG>"
        • the provided test script first does a GET \hello and displays the response
        • the script does a POST to \echo with the user input <MSG> and displays the response
      • or use curl (asssuming IP is 192.168.43.130):
        1. "curl 192.168.43.130:80/hello" - tests the GET "\hello" handler
        2. "curl -X POST --data-binary @anyfile 192.168.43.130:80/echo > tmpfile"
          • "anyfile" is the file being sent as request body and "tmpfile" is where the body of the response is saved
          • since the server echoes back the request body, the two files should be same, as can be confirmed using : "cmp anyfile tmpfile"
        3. "curl -X PUT -d "0" 192.168.43.130:80/ctrl" - disable /hello and /echo handlers
        4. "curl -X PUT -d "1" 192.168.43.130:80/ctrl" - enable /hello and /echo handlers
  • If the server log shows "httpd_parse: parse_block: request URI/header too long", especially when handling POST requests, then you probably need to increase HTTPD_MAX_REQ_HDR_LEN, which you can find in the project configuration menu (idf.py menuconfig): Component config -> HTTP Server -> Max HTTP Request Header Length

See the README.md file in the upper level 'examples' directory for more information about examples.