Comments (13)
Some servers send me a gzip-compressed response without me asking for it, so practically I must always be prepared for such responses.
Unfortunately the RFC's language isn't very clear what the server is supposed to do if no Accept-Encoding
header is sent. From RFC 2616:
If no Accept-Encoding field is present in a request, the server MAY assume that the client will accept any content coding.
https://tools.ietf.org/html/rfc2616#section-14.3
From the newer RFC 7231:
A request without an Accept-Encoding header field implies that the user agent has no preferences regarding content-codings. Although this allows the server to use any content-coding in a response, it does not imply that the user agent will be able to correctly process all encodings.
https://tools.ietf.org/html/rfc7231#section-5.3.4
from hyper.
Compression specifically could be left up to downstream things to implement. Not sure this is the domain of an http library.
from hyper.
Looking through the spec, it does seem like its an optional thing, as opposed to chunked which the spec says a server MUST understand chunked to 1.1 compatibile.
from hyper.
See also https://stackoverflow.com/questions/8364640/how-to-properly-handle-a-gzipped-page-when-using-curl
from hyper.
A header of "Accept-Encoding: identity" means the user agent is
specifically requesting no compression. Does that help your case?
On Sat, Jan 23, 2016, 11:22 AM Markus Unterwaditzer <
[email protected]> wrote:
See also
https://stackoverflow.com/questions/8364640/how-to-properly-handle-a-gzipped-page-when-using-curl—
Reply to this email directly or view it on GitHub
#2 (comment).
from hyper.
Probably, though I'd still prefer if Hyper handled this transparently for me (even if behind a featureflag).
Would setting this as a default header (on Hyper's side) be acceptable?
from hyper.
I'm not so certain that this is a decision that hyper should default to. As you noticed in 7231, sending no header is valid, and implies no preference. If a user of hyper hasn't stated otherwise, I don't think we can assume a preference.
A higher level Client wrapper would probably be the place to be more opinionated, methinks.
from hyper.
This has bitten me again. This time a different library, @SimonSapin's kuchiki provides a parse_html().from_http(url)
interface, but doesn't explicitly set a header. The result is a garbage DOM.
If a user of hyper hasn't stated otherwise, I don't think we can assume a preference.
If a user of hyper hasn't stated otherwise, I don't think we can assume they'd thought about it.
from hyper.
Again, does asking for identity fix the issue?
from hyper.
Sorry, it seems to be an issue with the server in this case.
EDIT: Yes, in the previous instance, setting Accept-Encoding: identity helped.
from hyper.
(@untitaker I’ve extended kuchiki’s from_http
to also except an hyper::client::Response
so that you can set headers and make the request yourself. In that case, the point of using it from_http
instead of read_from
with a Response
as a generic std::io::Read
is that it gets the charset
from Content-Type
, if any.)
from hyper.
@seanmonstar is it possible to set the headers once per client, so that we don't have do add them with every request?
from hyper.
@Trolldemorted not in hyper. Such a feature does exist in reqwest, though!
from hyper.
Related Issues (20)
- Flaky benchmark for http2 with adaptive window HOT 1
- proto/h1: spurious copy-allocation in request parsing hotpath HOT 4
- graceful shutdown does not shutdown when i use Google Chrome。 HOT 4
- hyper-util: add test for graceful shutdown
- The performance problem of hyper v1 gateway of http1 with the log4rs HOT 5
- hyper-util auto version detection breaks the ability to use `Upgraded::downcast` HOT 2
- http1.1 protocol downgrade
- Expose Service and HttpService without features HOT 2
- [0.14.x] Expose `hyper::client::connect::http::ConnectError` HOT 2
- `Uri` shouldn't accept curly braces (`{`, `}`) in path parts HOT 9
- Futures-util dev dependency should require alloc feature HOT 3
- Problems building hyper on linux for curl CI HOT 2
- Need an examples of http2 client for hyper
- Expose a function to check if a `hyper::Error` is due to a `BodyWrite` HOT 2
- Memory Leak in case of "IncompleteMessage: connection closed before message completed" HOT 3
- Hyper server hangs when handling a request from a client on the same host (not necessarily the same process) HOT 2
- Panic on graceful shutdown for http/1
- HTTP2 Max Streams aware client pooling HOT 5
- Support HTTP2 upgrades with !Send executors HOT 2
- Panic in `UpgradeableConnection` due to `unwrap`
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 hyper.