snoyberg / http-enumerator

HTTP client package with enumerator interface and HTTPS support.
27 stars 9 forks source link

Support connection keepalive #5

Closed bos closed 13 years ago

bos commented 13 years ago

I have a client that needs to hit a single server:port with a lot of POST requests, and I'm running out of sockets very rapidly because http-enumerator lacks keepalive support.

snoyberg commented 13 years ago

This is definitely a feature I have been planning on adding. Do you have any ideas of what an API for this might look like? I have some ideas that would involve running everything within a special monad, but I would overall prefer a light-weight approach.

bos commented 13 years ago

I think maybe just having a Manager value that you pass in, where any possible kept-alive connections would be managed, should be just fine. This would allow separate managers for different threads, for instance.

vincenthz commented 13 years ago

using a manager value would make the streaming api ghc7 specific isn't it ? that would be a bit unfortunate since ghc7 is not yet the "default" ghc.

snoyberg commented 13 years ago

I took the "Manager" value to just be something like:

newtype Manager = Manager (MVar (Map (Host, Port, IsSecure) Socket))

Did you mean something different Bryan? Overall this seems fine, though I'm not quite certain how it will play out with https connection due to handshake issues, I'll still need to look into that.

bos commented 13 years ago

I did indeed mean exactly what you suggest, Michael. Thanks for clarifying :-)