-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
content-encoding aware string parsing & encoding #34
Comments
Talked with @yoshuawuyts, and we believe the point of integration is overwriting to the |
I think this should be a property of the i'm tinkering with making a on the http-types end, the |
@goto-bus-stop What I'm wondering about is: are there any cases where we wouldn't want to decode based on the encoding type? I suspect the answer here might be "probably not", which is: maybe we should handle this out of the box? So the proposed API would change: Previous proposallet req = Request::new(Url::new("https://example.com"));
let reader = req.into_utf8_reader();
let mut s = String::new();
reader.read_to_string(&mut s).await?; Current proposallet req = Request::new(Url::new("https://example.com"));
let mut s = String::new();
req.read_to_string(&mut s).await?; The biggest question remaining then seems: do we need an escape hatch? I'm not sure tbh. Perhaps there could be a flag on the let req = Request::new(Url::new("https://example.com"));
let mut body = req.into_body();
body.decoder(false);
let mut s = String::new();
body.read_to_string(&mut s).await?; |
When encoding a stream we indeed don't assume anything, and set octet-stream. But for strings we correctly set When decoding a stream we don't do anything with text encodings. Most of my previous comment was about decoding only. Is there anything about encoding you think we should be doing? |
for encoding we probably don't need non-utf8 support (certainly not initially). it would be kinda strange in 2020 to write a server in a cutting-edge language and framework if you need to service clients that don't support utf8 (do they exist?). i was primarily wondering about decoding as well, since the Body does not know what its encoding is when it receives a response (assuming http-types use on the client-side). I think the I don't think we need a custom escape hatch since you can already get the raw bytes. If you really want to use utf8 for some reason even if the server explicitly advertises a different encoding, you can do |
I think we could indeed use |
Similar to http-rs/surf#101 and http-rs/surf#108 we should make string parsing and encoding aware of the
Content-Type
header.cc/ @goto-bus-stop; pinging you here since you contributed the patch to Surf; we're planning to move Tide and Surf both over to
http-types
, so figured it'd make sense to include the work you've done here.The text was updated successfully, but these errors were encountered: