Comments (10)
I'm quite a 👎 here.
- It could only ever support HTTP/1, not 2. That would feel weird to me.
- Parsing is opinionated. We wouldn't want anyone to not use this crate because they felt the parsing was not done the way they wanted.
- Parsing should be out of scope for what a user wants. A user should use this crate because they want to define the ability to receive or make requests and responses. How a bucket of bytes becomes those things should be up to any implementation.
- As Carl mentions, any flaw in the parsing API would never be fixed at the expense of breaking backwards compatibility with everyone, when the main goal is to use the types.
from http.
Big 👍 here, right now I'm integrating httparse to do this, and it works okay, but it'd be nice to have it handled by the library. It also has some symmetry with Uri::parse.
from http.
IMO parsing is slightly out of scope for the crate, though it doesn't seem to hurt too much to add.
The main drawback that I see is that parsing could be a lot more opinionated and we will doubtfully ever trigger a breaking change release to fix parsing APIs. Aka, I would regard any parsing apis as "second class".
from http.
I worked on this but I doubt the implementation we would have here would be one any production crate would use. Here are the issues I found:
- If we don't want parsing to be intertwined with reading (and it can't be at this level because of the difference between blocking and nonblocking reads), users will need to be reading newlines to the end of the header. And this is setting aside the issue of reading the body (which requires figuring out which length header to use and then reading that much data).
- HTTP\1.1 is a "helpfully" flexible spec, making correct parsers very complex - we're supposed to support arbitrary linear whitespace, both
\n
and\r\n
line separates, headers broken up over multiple lines, etc.
I decided if we're going to do this its definitely not an 0.1 blocker, and we should decide up front exactly what we're supporting.
We do parse each individual component of a message (though I think version validating was removed recently for reasons I didn't really understand), which should make it easier to implement a parser.
from http.
This definitely should not block 0.1.
from http.
@seanmonstar I can understand this perspective, and it makes sense. However, I'd argue that including URI parsing runs into basically the same issues, no?
To me, it's mostly weird that there's one kind of parser, but not another.
from http.
Uri parsing is a FromStr
impl and is going to be much more common to use in end user apps than parsing from an h1 payload.
The httparse
create could easily add support for parsing here.
from http.
It seems to me that the http crate is actually doing some parsing -- it looks quite optimised as well, for instance, URIs, Header Names and Http Methods.
At the moment it looks like two parsing stages are needed. One stage gets the parts ready for the http crate and then the work done in the http crate itself. To me, this seems like a waste when you consider the system as a whole.
One thing that would be nice for me is if the first parsing stage that I do myself is as easy as possible. This would be helped by having all parts consistently readable from a byte array e.g Http Version. At the moment Http Version must be parsed outside the http crate.
from http.
The crate should provide "unchecked" constructor variants that let HTTP implementations that have already performed parsing to just load the types. These should be added as needed when there is a measurable benefit.
The main reason there is parsing implemented for types like URI, headers, and method is that there is that those functions are useful for the end user (i.e. not HTTP client / server libs).
Again, I think it would be fine for httparse
to provide all of the parsing as the recommended HTTP parser.
from http.
The conclusion here is that there will be no parsing added to the crate.
from http.
Related Issues (20)
- Clear contents of sensitive header values on drop HOT 2
- Why does canonical_reason() return a Option? HOT 3
- Rename 422 from "Unprocessable Entity" to "Unprocessable Content"
- const fn for `StatusCode::as_u16` HOT 1
- can't parse uri without scheme but having path HOT 4
- 1.0 vs 0.2 incompatibility HOT 1
- Allow customizing header casing
- Add a `Display` impl for `Request` and `Response` to reconstruct the raw HTTP message HOT 2
- impl std::error::Error for StatusCode HOT 1
- http::method::Method::FromStr implementation allows invalid methods, conflicting with from_str documentation HOT 2
- Invalid uri parse HOT 1
- `http::uri::Uri` is excessively large and makes unnecessary allocations HOT 2
- Failed to parse a valid url HOT 1
- Uri does not parse valid URIs with empty authority portion HOT 1
- Add 420 Enhance Your Calm status code
- How to append a queryparams string after using uri_mut().into_parts()? HOT 1
- `index out of bounds` when parsing a valid header value HOT 2
- Request headers containing Russian (and possibly other non-English) characters fail with `UTF-8 encoding error` HOT 1
- HeaderMap::try_with_capacity can panic when capacity is large
- RFC: Add `parts_mut() -> &mut Parts` to allow mutate parts directly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http.