Giter VIP home page Giter VIP logo

Comments (9)

carllerche avatar carllerche commented on August 15, 2024

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.

alexcrichton avatar alexcrichton commented on August 15, 2024

We could change headers?

from http.

carllerche avatar carllerche commented on August 15, 2024

We could... the extend behavior also seems useful to have as well, but I couldn't think of a great name.

from http.

alexcrichton avatar alexcrichton commented on August 15, 2024

Maybe something like headers_reset?

from http.

carllerche avatar carllerche commented on August 15, 2024

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.

seanmonstar avatar seanmonstar commented on August 15, 2024

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.

carllerche avatar carllerche commented on August 15, 2024

@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.

seanmonstar avatar seanmonstar commented on August 15, 2024

If we aren't certain that headers should extend (append), then seems prudent to remove it for now. 👍

from http.

carllerche avatar carllerche commented on August 15, 2024

After removing the headers fn, this issue can be fixed post 0.1.

from http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.