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
5
votes
1 answer

Why are multiple imports from the Hyper crate failing?

I'm working on a very simple HTTP client in Rust, built on top of the hyper (GitHub, crates.io) crate. When I try to replicate the examples/client.rs file in a new Cargo project using cargo build (as well as using rustc src/main.rs), I get multiple…
Jules
  • 14,200
  • 13
  • 56
  • 101
4
votes
1 answer

How to correctly read a string value from an outer scope within an async closure for Hyper in Rust

I'm trying to learn Rust, and trying to write some extremely simple web server code to do so. I thought I had a good idea of the basics of lifetimes & borrowing in simple code, but I'm finding that either I'm missing a basic technique somewhere, or…
Tim Perry
  • 11,766
  • 1
  • 57
  • 85
4
votes
1 answer

How to exclude a particular crate-type from build?

My Rust project depends on crate reqwest which depends on hyper. When I build my project for Android platform cargo.exe build --target aarch64-linux-android cargo cannot find cc. Compiling hyper v0.14.4 error: linker `cc` not found = note: The…
iggr
  • 41
  • 4
4
votes
1 answer

How to send chunked transfer-encoded hyper response?

I am trying to send a hyper response with a specific number of bytes and chunks. I've been lost on how to generate a generic chunked response or set the transfer-encoding header. There seemed to be a httpWriter/chunkedWriter for hyper which is now…
omgpopstar
  • 97
  • 5
4
votes
2 answers

How to read the response body as a string in Rust Hyper?

This question has several answers (here, here, and here), but none of them worked for me :( What I've tried so far: use hyper as http; use futures::TryStreamExt; fn test_heartbeat() { let mut runtime =…
nomad
  • 131
  • 1
  • 8
4
votes
2 answers

How to create a Stream from reading and transforming a file?

I'm trying to read a file, decrypt it, and return the data. Because the file is potentially very big, I want to do this in a stream. I cannot find a good pattern to implement the stream. I'm trying to do something like this: let stream =…
user1783732
  • 1,599
  • 5
  • 22
  • 44
4
votes
1 answer

How to fix the trait `std::convert::From` is not implemented for `hyper::Body`?

I have a http-client building with hyper. And I try to send json data with method post: fn run_client() { let json = json!({ "list": [ { "id": 1, …
Sergey
  • 353
  • 1
  • 3
  • 12
4
votes
1 answer

How can I serve static files / a directory in hyper?

I want to serve some static files (.js, .css, ...) from my hyper server. Currently the only way I can think of is inlining the files as strings / load them on startup. Is there a better way to directly serve an entire directory or selected files?
I3ck
  • 433
  • 3
  • 10
4
votes
0 answers

How to store hyper::server::Server with a default handler as a struct field in a constructor?

I am trying to store a hyper::server::Server as a member of my struct (struct MyApp below). I can do this from, for example, my program's main() function. How can I do this in my struct's MyApp::new() method? I think I need the concrete type for F…
Andrew Straw
  • 1,138
  • 12
  • 15
4
votes
1 answer

How to bind a request to a specific network interface with Rust Hyper HTTP client?

I have a Linux server with multiple network interfaces. Each interface has its own IP address. How to force HTTP requests to use a specific interface by specifying its IP address? Just like curl --interface command line option.
4
votes
2 answers

How to test a Hyper server HTTP handler function?

My application uses the hyper crate to serve some data over HTTP. The core is a handler function, like this: struct HttpHandler {} impl hyper::server::Handler for HttpHandler { fn handle(&self, req: hyper::server::Request, res:…
pixelistik
  • 7,541
  • 3
  • 32
  • 42
4
votes
1 answer

How to reach an HTTPS site via proxy with Hyper?

The following is an attempt to reach an HTTPS site via proxy: extern crate hyper; extern crate hyper_native_tls; use hyper::net::HttpsConnector; use hyper::client::{Client, ProxyConfig}; use hyper_native_tls::NativeTlsClient; fn main() { let…
tshepang
  • 12,111
  • 21
  • 91
  • 136
4
votes
1 answer

Using both git2 and hyper: openssl linked more than once

I'm trying to build something which is using both hyper and git2 at the same time. Now I've got a problem with openssl being linked twice. A tip by shepmaster lead me to Cargos features and I tried that but I'm still stuck. The precise error I'm…
Machisuji
  • 738
  • 7
  • 16
4
votes
1 answer

How to get the Authorization Bearer header?

I would like to get the Authorization Bearer header for OAuth purposes, but it looks a bit confusing reading the docs use nickel::{Nickel, JsonBody, HttpRouter, Request, Response, MiddlewareResult, MediaType}; // Get the full Authorization…
Marcos
  • 43
  • 3
3
votes
1 answer

error[E0277]: the trait bound `Request: serde::ser::Serialize` is not satisfied

I am trying to output the Hyper HTTP Request Object as JSON. I am using Serde to Serialize the object to JSON. Since I am not defining the HTTP Request Struct, I can't add the attribute #[derive(Serialize, Deserialize)] to it. any ideas on how to…
JOW
  • 244
  • 4
  • 18
1 2
3
17 18