How do I parse an http request from tokio::net::TcpStream into hyper::http:Request? #2810
-
Hey everyone. KInda new to async. I was looking into the documentation and could not find a way to parse a raw HTTP request read from a TCP stream into the HTTP Request struct. Is there a way to do that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you're looking to use hyper to handle the HTTP for you, then you want to look at If you want to implement HTTP yourself, exactly how you decide to parse and encode is up to you. HTTP has a lot of edge-cases, so I don't recommend it. But if you really wanted, you look at using something like the |
Beta Was this translation helpful? Give feedback.
If you're looking to use hyper to handle the HTTP for you, then you want to look at
hyper::server::conn::Http
.If you want to implement HTTP yourself, exactly how you decide to parse and encode is up to you. HTTP has a lot of edge-cases, so I don't recommend it. But if you really wanted, you look at using something like the
httparse
crate, and then convert the parsed types intohttp::Request
.