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

How to use HTTP proxy with asynchronous Hyper 0.11 in Rust?

How do I send an HTTP request using a proxy with Hyper 0.11? I have the following working code that sends an HTTP request without proxy: extern crate hyper; extern crate tokio_core; extern crate futures; use futures::Future; use hyper::Client; use…
Sergey Potapov
  • 3,819
  • 3
  • 27
  • 46
18
votes
3 answers

How do I read the entire body of a Tokio-based Hyper request?

I want to write a server using the current master branch of Hyper that saves a message that is delivered by a POST request and sends this message to every incoming GET request. I have this, mostly copied from the Hyper examples directory: extern…
JayStrictor
  • 468
  • 1
  • 4
  • 10
15
votes
3 answers

Parsing HTML page content in a stream with hyper and html5ever

I'm trying to parse the HTML response of an HTTP request. I'm using hyper for the requests and html5ever for the parsing. The HTML will be pretty large and I don't need to fully parse it -- I just need to identify some data from tags so I would…
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
13
votes
1 answer

How is Reqwest higher level than Hyper?

According to the docs on Hyper.rs, If you are looking for a convenient HTTP client, then you may wish to consider reqwest. If you are looking for a convenient HTTP server, then you may wish to consider warp. Both are built on top of this…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
12
votes
1 answer

Hyper says "Invalid scheme for Http" for HTTPS URLs

I have hyper = "0.10" And the following code: let client = Client::new(); let mut res = client.get("https://google.com").send().unwrap(); Rust gives me the error message, as if it doesn't have SSL support: Invalid scheme for Http This is on Rust…
njaard
  • 529
  • 4
  • 15
10
votes
1 answer

How to store a hyper::server::Server as a field in a struct?

I have a library which uses hyper internally. I want the user to be able to create an Appwhich contains a Server internally that handles HTTP connections. use hyper::server::conn::AddrIncoming; use hyper::server::Server; use…
muskox
  • 103
  • 3
9
votes
4 answers

How can I change the theme of my Hyper Terminal (downloaded from hyper.is)?

If you have any experience with the downloadable software "Hyper" which is basically just a terminal, then you might be able to help me. I can't change the theme, its look. I am on the newest version of MacOS. I tried opening the file hyper.js but…
user13801785
8
votes
2 answers

`RefCell` cannot be shared between threads safely?

This is a continuation of How to re-use a value from the outer scope inside a closure in Rust? , opened new Q for better presentation. // main.rs // The value will be modified eventually inside `main` // and a http request should respond…
rollingBalls
  • 1,808
  • 1
  • 14
  • 25
8
votes
2 answers

How to post an image using multipart/form-data with hyper?

I'm trying to post an image file using hyper like cURL does: curl -F smfile=@11.jpg https://httpbin.org/post --trace-ascii - The result is: { "args": {}, "data": "", "files": { "smfile": "data:image/jpeg;base64,..." }, "form": {}, …
user2986683
  • 297
  • 1
  • 4
  • 12
8
votes
1 answer

Running websocket and http server on the same port (Rust, hyper)

I want to write a webserver using Rust, Hyper and websocket-rs. The webserver must be able to handle http requests AND websocket requests on the same port. I used the official sample (async-server.rs:…
cruppstahl
  • 2,447
  • 1
  • 19
  • 25
8
votes
2 answers

How to set timeout for HTTP request with hyper, tokio and futures in Rust?

How do I set a timeout for HTTP request using asynchronous Hyper (>= 0.11)? Here is the example of the code without timeout: extern crate hyper; extern crate tokio_core; extern crate futures; use futures::Future; use hyper::Client; use…
Sergey Potapov
  • 3,819
  • 3
  • 27
  • 46
7
votes
1 answer

Hyper cannot find Server module

I'm writing a "hello world" HTTP server with Hyper, however I am not able to find the Server and rt modules when trying to import them. When invoking cargo run, then I see this error message: 26 | let server =…
TPPZ
  • 4,447
  • 10
  • 61
  • 106
7
votes
1 answer

How to write a hyper response body to a file?

I am trying to write a test program with tokio that grabs a file from a website and writes the streamed response to a file. The hyper website shows an example that uses a while loop and uses the .data() method the response body, but I'd like to…
broughjt
  • 73
  • 4
7
votes
1 answer

Getting a request from Hyper, parsing the JSON, and turning it into a struct in rust

I'm trying to make a webserver that accepts some parameters as JSON, and turns them into a struct which I'll then store somewhere else in my app. I have this data struct in a file called status.rs: use serde::{Serialize,…
GTF
  • 8,031
  • 5
  • 36
  • 59
7
votes
1 answer

Shared mutable state in Hyper

I'm trying to create a counter in a Hyper web server that counts the number of requests it has received. I'm using a Arc> to hold onto count. However, I haven't been able to figure out the right combination of move and .clone() to satisfy…
Michael Snoyman
  • 31,100
  • 3
  • 48
  • 77
1
2 3
17 18