http-rs / http-rs/surf

Add append_header to RequestBuilder or make header types fully public

Open
#362 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.5k
Forks
128
PR merge metrics
No merged PRs in 30d

Description

Currently, if i want to use RequestBuilder with multiple values for the same header, i have to construct a weird iterator using HeaderValue::from_str since the necessary tools to do this are missing.

I cannot:
- simply loop and call append_header, since RequestBuilder doesn't have this
- construct a Headers, since its private and i can't pass it to RequestBuilder
- construct and HeaderValues for RequestBuilder::header since its private

The only way i want to have multiple header values with RequestBuilder, i need to do this:
```rs
builder = builder.header(
name,
vec!["a", "b"]
.iter()
.map(|f| HeaderValue::from_str(f).unwrap().collect()),
);
```

which is quite clunky

Contributor guide

Open the contributing guide

Research direction

Start by locating RequestBuilder, Headers, and HeaderValue in the Surf source and inspect how the existing header method accepts values. Compare adding append_header with exposing the private types, then identify the API behavior needed for multiple values under one header name; done means callers no longer need the workaround shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.