Comments (9)
It is currently possible to set the HeaderMap
after building:
let mut request = Request::builder()
.method("get")
.body(());
*request.headers_mut() = my_headers;
This isn't super ergonomic or discoverable.
This issue is flagged as 0.1 as it might require breaking changes if Builder::headers
is renamed.
from http.
We could change headers
?
from http.
We could... the extend
behavior also seems useful to have as well, but I couldn't think of a great name.
from http.
Maybe something like headers_reset
?
from http.
I guess replace_headers
could work... It is unfortunate that all the other setters explicitly set the value except the one for HeaderMap
.
The other option would be to rename the current headers
fn -> insert_headers
.
Also, a thought occurs to me. Currently, headers
takes an into iterator of (K, V)
which has the possibility of having duplicate keys. HeaderMap
has two ways to handle duplicate keys (replace or append). Maybe having insert_headers
and append_headers
on the builder isn't too terrible?
from http.
Something that occurs to me is it doesn't sound like anyone is super convinced by any of the names. It's easy to add in methods later, but hard to fix these after they are added.
from http.
@seanmonstar I'm totally fine punting on adding fns. The real question here is what to do about the headers
fn that is currently part of the builder.
Maybe we should just yank it for 0.1 and defer figuring out what that fn should do.
from http.
If we aren't certain that headers
should extend (append), then seems prudent to remove it for now. 👍
from http.
After removing the headers
fn, this issue can be fixed post 0.1.
from http.
Related Issues (20)
- Clear contents of sensitive header values on drop HOT 2
- Why does canonical_reason() return a Option? HOT 3
- Rename 422 from "Unprocessable Entity" to "Unprocessable Content"
- const fn for `StatusCode::as_u16` HOT 1
- can't parse uri without scheme but having path HOT 4
- 1.0 vs 0.2 incompatibility HOT 1
- Allow customizing header casing
- Add a `Display` impl for `Request` and `Response` to reconstruct the raw HTTP message HOT 2
- impl std::error::Error for StatusCode HOT 1
- http::method::Method::FromStr implementation allows invalid methods, conflicting with from_str documentation HOT 2
- Invalid uri parse HOT 1
- `http::uri::Uri` is excessively large and makes unnecessary allocations HOT 2
- Failed to parse a valid url HOT 1
- Uri does not parse valid URIs with empty authority portion HOT 1
- Add 420 Enhance Your Calm status code
- How to append a queryparams string after using uri_mut().into_parts()? HOT 1
- `index out of bounds` when parsing a valid header value HOT 2
- Request headers containing Russian (and possibly other non-English) characters fail with `UTF-8 encoding error` HOT 1
- HeaderMap::try_with_capacity can panic when capacity is large
- RFC: Add `parts_mut() -> &mut Parts` to allow mutate parts directly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http.