Skip to content
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

Are HTTP connections closed after each call? #11

Open
pkazmier opened this issue May 15, 2020 · 4 comments
Open

Are HTTP connections closed after each call? #11

pkazmier opened this issue May 15, 2020 · 4 comments

Comments

@pkazmier
Copy link

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.

@DarrenN
Copy link
Owner

DarrenN commented May 15, 2020

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.

@DarrenN
Copy link
Owner

DarrenN commented May 15, 2020

You may also be interested in this thread racket/racket#3125 (comment)

@pkazmier
Copy link
Author

pkazmier commented May 15, 2020

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.

@jackfirth
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants