-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a http client implementation. #1388
Conversation
70498ca
to
85ea94b
Compare
85ea94b
to
1b6ebf3
Compare
1b6ebf3
to
43f9d76
Compare
*/ | ||
void *http_client_init(const char *hostname, pico_http_header_cb client_header_cb, pico_http_body_cb client_body_cb, void *arg); | ||
|
||
/*! \brief Initialise the http client to perform a https request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment should probably explain something about what _secure means
Other comments, 1/ Passing the hostname in http_client_init means you can't reuse the same "state" to make a request to a different host. Seems a bit restrictive? The only reason I can think for this is that your tls config might be related to the host you're talking to. It's easy enough to allocate "state" for each host? 2/ Can't run multiple requests at the same time? You could do this by calling http_client_init multiple times for the number of requests you want to have running at the same time. The lwip api just allocates a new state for each request and frees this in the callback. We could do the same but it seems wasteful when you want to make multiple requests one after another (to the same host). |
Yeah, perhaps have a friendly API which combines the underlying "state" init, and the actual request, but expose the underlying methods too. I guess I need to understand what the thing we are initializing is (it's life time) to know what it should be called (is it actually a client instance, a connection, etc.?) |
It looks like the lwip api is per http request - which is a bit naff. This was just supposed to be a "helper" utility to make the lwip functionality a bit easier to use (and hide the lwip dependency). Originally it was just part of the example code but I thought that was a bit lazy and should maybe add it to the sdk. Maybe I should forget that. |
Implemented using the lwip http client. Fixes raspberrypi#1386
43f9d76
to
aeae442
Compare
I pushed a new version. To make an http request is something like this...
I'm not sure this is adding a lot of value, so I might just move it back to pico-examples. What do you think? |
This has been moved into a http client example to demonstrate how to use the lwip http client |
Implemented using the lwip http client.
Fixes #1386