Skip to content

aiohttp.Client can't parse Trailer headers and throws exception #1619

Closed
@yurifedoseev

Description

Long story short

I work with some storage service via http. It sends me chunked response and several trailing headers after the body. All of this trailers are specified in a Trailer header according to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer

First problem: the client completely ignores this headers and doesn't parse them. Such behaviour violates HTTP 1.1

However, there is a bigger problem. If you use a single session the parsers would start the next parsing from the previous (!) response - beginning from these trailing headers. So the parser thinks it's the first line of new response and throws exception because it didn't find HTTP verb in it.
Therefore I can't reuse session in my app which leads to performance problems :(

Expected behaviour

  1. The client has to parse trailing headers in chunked response
  2. The next response should not be affected by any data from previous

Actual behaviour

  1. Client ignores trailer headers.
  2. The next response is affected by trailer headers from previous. The parser throws BadStatusLine exception.

Steps to reproduce

  1. Create server which respond which send chunked response with trailing headers after the body. A special Trailer header should be placed before the body and contains all trailing headers names.
  2. Create a new ClientSession. All next responses do via this session
  3. Send the first request to your server. You won't find any trailer headers in the response
  4. Send the second request. The client session will throw exception BadStatusLine

Checked on macOs 10.12.3 and Ubuntu Trusty 14.04

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions