Giter Site home page Giter Site logo

Comments (7)

reem avatar reem commented on April 28, 2024

There are really two potential answers to this question, as I see them:

  1. You use the forthcoming raw Headers instead of the higher level API supplied by normal hyper. The RawHeaders API will be much more amenable to this sort of thing.
  2. You await a new, more ergonomic raw API in the new top-level Headers supplied by normal hyper, which will have facilities for the runtime insertion of headers from raw strings.

Alternatively, you expose a typed interface instead of a (&str, &str) one. This would work by you just receiving an H: Header and using the typed interface of hyper headers instead of the raw one.

I recognize that this doesn't solve your problem right now, and ergonomic header access is something we have been thinking about a lot and hope to solve in the near future.

from hyper.

gtolle avatar gtolle commented on April 28, 2024

Thanks for the quick reply and suggestions.

I'll definitely look into the RawHeaders API when it arrives, and keep an eye on issue #50.

This is just a fun side project for me, so no worries about not solving my problem. :)

from hyper.

seanmonstar avatar seanmonstar commented on April 28, 2024

I'd emphasize the typed API, as it's cleaner and safer. Using it means less
crashes for everyone. I'd recommend that you provide both APIs, so that
people who want the safety can use it.

However, as @reem mentioned, we do want to provide a raw interface, when
it's not possible to know headers at compile time. Main driver is Servo,
exposing things like xhr.getResponseHeader("foobaz") in the DOM.

from hyper.

gtolle avatar gtolle commented on April 28, 2024

That makes sense. I'll definitely look into that.

Side question: I'm implementing my own Authorization header now, and I'm finding myself wanting to reuse the from_one_raw_str function you've already written. Any objection to making that pub?

from hyper.

reem avatar reem commented on April 28, 2024

@gtolle I don't see why not other than it should then be moved into a util module inside of header::common instead of being at the top level. I would also be happy to accept a PR with an implementation of the Authorization header as a relatively common header we should have support for in hyper.

from hyper.

s-panferov avatar s-panferov commented on April 28, 2024

+1 for PR, i like to see this header too

from hyper.

seanmonstar avatar seanmonstar commented on April 28, 2024

There exists headers.set_raw(&str, Vec<Vec<u8>>).

from hyper.

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.