It was possible to create such an object, but it would not serialize -> parse roundtrip. The alternative would be to reject paths without a leading /
When we perform a HEAD request and get a response with a chunked transfer-encoding, there's no point in looking for a body at all. We should just close the response immediately. Fixes #601
It is more reliable to split on "," and then strip the whitespace around each part of the Transfer-Encoding than it is to split on ", ". Further, since we don't have to create a list, we just setup a generator to allow us to inspect the Transfer-Encodings the server returns.
The Transfer-Encoding header can contain many values separated by a comma, e.g., Transfer-Encoding: chunked, gzip If we want to check for chunked transfer encodings we're better off not looking for equality since the above header value also indicates a chunked body. Instead, we need to split on ", " to ensure we can accurately determine if a response is chunked.
This refactors both the work in 2cfc216 and the work that originally caused the bug. This splits out some of the responsibility for handling chunks sent over the wire to two other methods. We move the compression handling to the read_chunked method since some users may actually wish to use that. By adding the optional decode_content parameter, we allow stream to simply pass the value through to read_chunked.