Are HTTP connections closed after each call?
Hi,
I’m looking for a simple library to make HTTP requests, similar to Python’s venerable requests module. While simple-http looks like a good candidate, after reviewing the code, it seems that there is no way to keep the HTTP connection open, which seems at odds with this stated use case in the documentation:
The general use case for this is when you want to make repeated requests to an API.
I’m trying to decide on a new language to learn. One of my initial criteria is whether there is an HTTP library that I can use to make repeated HTTP requests efficiently to an API. Am I correct that each HTTP call opens a new HTTP connection to the server? I have no Racket experience, so maybe I misread the code.
No this library doesn't re-use connections, that's not the intent of that statement. To re-use a single connection you may want to look at https://docs.racket-lang.org/http/index.html
That library will provide the primitives to do what you want, you could build up your own abstractions if necessary.
You may also be interested in this thread https://github.com/racket/racket/pull/3125#issuecomment-618498256
Thank you for the references. I will continue reading.
I am a bit disappointed to find that there is not a comparable library to Python’s requests. This is not a criticism of your package, but rather of Racket’s claim of being a “batteries included” language. It gives me pause about my consideration of Racket as a new language to learn. If it does not yet have a package for one of the most practical / real world tasks (for me at least), it makes me wonder what else might be missing. I’m just looking to add a new practical, yet not widely used, language to my toolbox to learn different paradigms, but one where I don’t need to reinvent the wheel to be productive. I also had Rust on my list to consider, might start there now.
As someone who has written several not-so-good ones, good HTTP clients are hard to write. If you're interesting in helping out @DarrenN without reinventing the wheel, then an FFI wrapper around libcurl so we can use HTTP/2 and HTTP/3 would be a great way to improve things. Racket's community is several orders of magnitude smaller than Rust's, so there are lots of gaps in the ecosystem.