pydantic / pydantic/httpx2

Trailing Headers

Open
#435 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
76
Avg merge
8h 59m
Merged PRs (30d)
24

Description

Originally opened by @tomchristie on 2020-08-08 10:49:55 in encode/httpx

One HTTP/1.1 feature that we don't currently support is trailing headers.

Hardly a high priority since it's seems so rarely used, but it might be worth our while someday.
It'd be interesting to hear from folks who do have use-cases here.

One option at the Transport API layer might be to update the AsyncByteStream/SyncByteStream APIs in order to handle this, without affecting the majority of code that doesn't expect or care about trailing headers, for example...

def get_trailing_headers() -> List[Tuple[byte, byte]]:
    # This method depends on the state of `__iter__`/`__aiter__`.
    # Once the byte stream has been fully consumed, any trailing headers may be accessed via this method.
    return []

At the httpx level we could expose this information by mutating the response.headers once the stream has been iterated over.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the AsyncByteStream and SyncByteStream transport APIs, then trace how streamed responses expose headers. Explore the proposed trailing-header accessor and how response.headers could be updated after full stream consumption. Done means HTTP/1.1 trailing headers are supported without affecting streams that do not use them.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.