aspnet / HttpAbstractions

[Archived] HTTP abstractions such as HttpRequest, HttpResponse, and HttpContext, as well as common web utilities. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
382 stars 193 forks source link

Useful helper methods for common http scenarios #429

Closed davidfowl closed 7 years ago

davidfowl commented 9 years ago

I was looking at golang's standard library and they have a pretty beefy http package https://golang.org/pkg/net/http. Here are a few that seemed interesting:

https://golang.org/pkg/net/http/#Request.WriteProxy https://golang.org/pkg/net/http/#ServeContent https://golang.org/pkg/net/http/#Request.SetBasicAuth (sorry @blowdart :smile: ) https://golang.org/pkg/net/http/#DetectContentType https://golang.org/pkg/net/http/#MaxBytesReader

blowdart commented 9 years ago

I'm surprised you're not saying sorry about DetectContentType - that is way more concerning than Basic Auth, although at least they're not picking some of the more dangerous ones.

Tratcher commented 9 years ago
davidfowl commented 9 years ago

WriteProxy is for clients, not servers.

Not sure what you mean. If you look at their API it writes to a "Stream" equivalent. This might be any network stream that is proxying requests over to another server even. It doesn't need to map directly to HttpClient.

MVC already handles many of these, correct? Static files implements them, but that implementation wouldn't be generally applicable because it relies on SendFile.

Moving building blocks into HttpAbstractions would be great. Even simpler versions that didn't rely on MVC intrinsics would be a good start.

muratg commented 8 years ago

@davidfowl Moving out of V1. If you think this is a MUST, bring it back