Merge Vary header

Open
#543 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
rust
Domain
api, backend

Research direction

Start by reproducing the provided ServiceBuilder stack with CorsLayer and CompressionLayer, then inspect the resulting response headers. Trace how each layer writes Vary and review the issue discussion for the intended behavior; done means the expected merging or separate-header behavior is established and covered by an appropriate test.

Written by the indexing model from the issue text.

Description

Is this okay Vary header don't merge with Vary header from response (other layers)? each layer should add Vary header?

Here layers

let middleware_stack = ServiceBuilder::new()
        .layer(
            CorsLayer::new()
                .allow_origin(AllowOrigin::list(vec![
                    "http://test.com".parse::<HeaderValue>().unwrap(),
                    "http://example.com".parse::<HeaderValue>().unwrap(),
                ]))
                .allow_methods([Method::GET, Method::POST])
        )
        .layer(
            CompressionLayer::new()
                .quality(CompressionLevel::Best)
        );

Here resposne

HTTP/1.1 200 OK
content-type: application/json
vary: origin, access-control-request-method, access-control-request-headers
vary: accept-encoding
content-length: 109
date: Wed, 05 Feb 2025 17:45:27 GMT
Dominant language
Rust
Stars
913
Forks
231
Avg merge
1d 20h
Merged PRs (30d)
8

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.

More from tower-rs/tower-http

All issues in tower-rs/tower-http

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.