Questions tagged [hyper]

A fast and correct HTTP implementation for Rust.

Hyper is a fast, safe HTTP implementation written in and for Rust.

  • A Client for talking to web services.
  • A Server for building those web services.
  • Blazing fast* thanks to Rust.
  • High concurrency with non-blocking sockets.
  • HTTP/1 and HTTP/2 support.

Github Repository

Guide

256 questions
1
vote
1 answer

Lifetime error when implementing AsyncWrite to hyper Sender

I need to covert the hyper::body::Sender to a tokio::io::AsyncWrite and pass it to one of my reusable function. That function is platform agnostic and can be used for any io operation. That's why I am taking an AsyncWrite as a parameter. First I…
1
vote
2 answers

What is the optimal way to make external network requests using Axum, Tokio, and Hyper in Rust?

I have written pretty basic rust server which makes http call to defined url in environment variable, parse json response and return. Source Code | Flamegraph - IO Call | Dockerfile | Flamegraph - Static Json Nginx request - throughput ~30000…
pratik
  • 178
  • 11
1
vote
0 answers

Wrap a hyper::Body in a BufReader in Rust

I have a hyper::Body and I want to wrap it in a BufReader (for example tokio::io::BufReader, but futures_util::io::BufReader or any other is fine too). Using it directly didn't work: fn foo(body: hyper::Body) { let bufreader =…
kpcyrd
  • 11
  • 2
1
vote
1 answer

How can I receive data by POST in Hyper?

What I want to do is really what the title says. I would like to know how I can receive data per post in hyper, for example, suppose I execute the following command (with a server in hyper running on port :8000): curl -X POST -F…
DFG
  • 31
  • 1
  • 13
1
vote
1 answer

How can I return customizing headers in hyper? Rust

What I want to do is return custom headers in hyper (but return them and return the response body as well) For example, I'm going to take the code from the hyper documentation as an example: async fn handle(_: Request) ->…
DFG
  • 31
  • 1
  • 13
1
vote
2 answers

Use hyper to pass IP address of incoming connection to stack of Services

I am trying to write a server using hyper that will pass the remote (client) address of the incoming connection down to a stack of Layers (that I have built using ServiceBuilder. I have tried to use examples from the hyper docs and also this example…
d2718
  • 175
  • 8
1
vote
1 answer

How to set http timeouts using axum (based on hyper)?

I'm coming from Golang where I can simply use http.Server struct for timeout options like: func start() { httpServer := &http.Server{ ReadTimeout: "30s", WriteTimeout: "1h", //... } err = httpServer.ListenAndServe() } I'm using…
Fred Hors
  • 3,258
  • 3
  • 25
  • 71
1
vote
0 answers

How can I copy a hyper::Request in Rust?

I'm making a proxy server using tokio and hyper. Depending on the request, there can be multiple proxy servers(can send request). I have the addresses of the servers to proxy as a vector and try to connect in turn. For example, when a GET /test…
yjlee
  • 363
  • 1
  • 14
1
vote
0 answers

hyper : implementation of `FnOnce` is not general enough

I'm trying to refactor code by moving the hyper server out of main and allow the struct function to accept a function as below: // main.rs #[tokio::main] async fn main() { let listener = Listener::new(String::from("127.0.0.1"),…
Silva
  • 625
  • 1
  • 6
  • 25
1
vote
1 answer

Deserializing hyper body into utf8 string: error[E0597]: `bytes` does not live long enough

I want to write a util where I deserialize a given request body into the target type (T): pub async fn read_json_body<'a, T>(req: &'a mut Request) -> T where T : Deserialize<'a> { let mut body = req.body_mut(); let bytes =…
code-gorilla
  • 2,231
  • 1
  • 6
  • 21
1
vote
0 answers

How do I pass details of a client certificate to a hyper HTTPS router?

I found this example, but it is not clear how to pass details of the client certificate to the router, such as the subject. I would like to implement some logic that depends on details of the certificate.
Anon
  • 51
  • 3
1
vote
2 answers

Hyper request as string

I would like to be able to print out the entire unparsed request so that I can easily see exactly what information the request contains. I could write a function to recreate the request string from the parsed request by iterating over all the…
Max888
  • 3,089
  • 24
  • 55
1
vote
1 answer

Why is there type mismatch when making a POST request using hyper 0.14 over TLS?

I am trying to construct a POST http request using hyper. I am using tokio_rustls to construct a https connector with tls. The code I am using is: use hyper::{body::to_bytes, client, Body, Method, Uri,Request}; let mut http =…
1
vote
0 answers

how to write a https server using RUST ?

as the title say,I want to write a https server,using hyper crate. async fn runmain() { let addr = SocketAddr::from(([127, 0, 0, 1], 25025)); let make_service = make_service_fn(|_conn| async { Ok::<_,…
Hunter
  • 43
  • 3
1
vote
0 answers

Creating routes dynamically at runtime with Warp?

I have a Rust app and I'd like to store routes in a database (it can be an in-memory mock for all I care), but I want to update routes at runtime. I'm ignoring a 404 route or other status routes and assuming anything off the root route of "/" would…
chum of chance
  • 6,200
  • 10
  • 46
  • 74