davidfowl / OwinHttpClient

Barebones http client that uses the owin interface built on .NET socket API.
Other
47 stars 14 forks source link

Nice API on top of OwinHttpClient #14

Open dragan opened 11 years ago

dragan commented 11 years ago

I've been fulling around starting a HttpClient for a while now that has a similar API to the Python Requests library. It has a hooks API as well which would be perfect for adding middleware to the request and response. I also need the ability to switch out the connection protocol from TCP to Unix sockets and is the main driving force behind why I need to create a new one.

I've started a project, but I remembered yours and thought I'd touch base first before continuing. Would you be interested in an API similar to Requests on top of the guts of OwinHttpClient? I see you mentioning in the README that the current API isn't set yet. Here's an example of what I've done:

// Static API, which uses a Session object underneath with defaults set
Response r = await Requests.GetAsync("http://httpbin.org/get");

// For finer grain control
var session = new Session();
session.Mount("unix", new UnixHttpAdapter());
Response r = await session.GetAsync("unix://path/to/unix.sock");

Of course the UnixHttpAdapter won't be a part of the project, I just need a way to incorporate it into the middleware so that the request goes through it instead of a Tcp connection.

I've already played with OwinHttpClient a little bit over the last couple of days and have it working on Mono, minus the Nancy and WebApi examples. I had to make quite a few changes and I'll be happy to submit a pull request.

Also, if you're not interested in maintaining the project anymore, I'd be happy to take it over instead of going any further with my project.

Let me know what you think.

davidfowl commented 11 years ago

Sounds like a plan. How do you propose we do the API? As part of the core library?

dragan commented 11 years ago

Great! I was thinking that it would be a part of the core library, but I'm open to other options as well. Just having one dll would be nice.

Also, I was going to call my project Chump if you'd like to use it for this one instead.

davidfowl commented 11 years ago

Not sure I want to hide any of the Owin API, maybe layer on top.

dragan commented 11 years ago

Yeah, that's my thought as well. We still leave the Owin API public, but the Requests API is just a layer on top.

dragan commented 11 years ago

To add to my last comment, probably use some namespaces to only show the Requests API at the top level namespace and the Owin API under a child namespace.