Comments (7)
There are really two potential answers to this question, as I see them:
- You use the forthcoming
raw
Headers instead of the higher level API supplied by normal hyper. TheRawHeaders
API will be much more amenable to this sort of thing. - 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.
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.
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.
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.
@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.
+1 for PR, i like to see this header too
from hyper.
There exists headers.set_raw(&str, Vec<Vec<u8>>)
.
from hyper.
Related Issues (20)
- hyper-util's docs are rendered without any features enabled HOT 1
- Hyper 0.14.27 deprecated/backports features don't produce any warnings, but can't upgrade to hyper 1.0 HOT 3
- UnexpectedEof Error on HTTP/2 Requests with Rustls HOT 16
- Error serving connection: hyper::Error(Http2, Error { kind: GoAway(b"", PROTOCOL_ERROR, Library) }) HOT 4
- Make send_file example streaming HOT 3
- hyper-util: add (tokio) Server struct and builder (inspired by Hyper 0.14) HOT 2
- [SSRF] Ability to prohibit connections to subnet ranges HOT 1
- Get some time informations about a request like curl/libcurl
- Harden against HTTP Desync attacks HOT 2
- ffi: different input and output types for tasks HOT 2
- Make examples usable (TokioIo) HOT 8
- CHANGELOG doesn't explain what happened to `hyper::Client` or `HttpConnector` HOT 8
- Documentation link in hyper::client::conn for "Higher-level Client API" should probably go to hyper-util now HOT 1
- First byte timeout HOT 1
- From v0.14 to v1 difficulties using Client HOT 1
- hyper-util Client examples are wrong HOT 1
- Upgraded does not impl AsyncRead/AsyncWrite in hyper 1.0 HOT 2
- Can not create hyper::Error HOT 3
- hyper-util missing `max_pending_accept_reset_streams` HOT 1
- There is no way to pass data to the new Server connection service in Hyper 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 hyper.