This is a fully featured HTTP client provided as part of ESP-IDF, including TLS, header parsing, chunked responses, etc.
Now you can use it in Micropython.
It can be useful for interacting with REST API, or simply for fetching data from the web.
Here is a simple example that shows how to send a GET request, print HTTP headers and read the payload stream:
The Micropython Binding uses the user_data pointer to save the Python callable object (the Python “callback”). When you pass None in this case it won’t set user_data C pointer to NULL, but allocate it for this puspose.
Under the hoods the user_data is really a Python dict, because the same user_data can be used with multiple callbacks and we may need to keep track of multiple callbacks with the same user_data.
The other option is to pass a dict as user_data. In that case the binding adds new entries to the dict instead of allocating a new one. This can be used (rarely) when you need to pass additional Python arguments to a callback, like in this case.