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

Hyper server drops connection on returning Async::NotReady in Future

I'm trying to run a hyper server with an asynchronous response on a request using a future. When the future's poll method is called and returns Async::NotReady, the connection is just dropped ("dropping I/O source: 0"). I expected that the poll…
Jones
  • 23
  • 2
2
votes
2 answers

Resolve to a tuple for a future

In rust, I am trying to fulfill a future by extracting two bits of data out of a .get request using a hyper client as a tuple. The problem is the resulting type doesn't work. So given some code like this: let result = client .get(url) …
Kitson
  • 1,650
  • 1
  • 18
  • 36
2
votes
0 answers

How do I structure a hyper HTTP app to handle shared state?

I'm trying to build a simple API server in Rust in order to learn the language better. This should accept some datum on PUT /data and store that datum (currently in memory to simplify the problem). I wrote a MemDb struct to handle inserting and…
GTF
  • 8,031
  • 5
  • 36
  • 59
2
votes
1 answer

"cannot recursively call into `Core`" when trying to achieve nested concurrency using Tokio

I'm building a service that periodically makes an HTTP request. I'm using tokio::timer::Delay as a periodic trigger and hyper to make the HTTP call. Using them together gives me the following error: thread 'tokio-runtime-worker-1' panicked at…
mchlstckl
  • 3,390
  • 2
  • 21
  • 21
2
votes
1 answer

hyper client cannot lookup address information for server running on IPv6 localhost

I have a simple HTTP server using Router and Iron on port 3005. It is not doing anything exciting. I believe it just echoes back the request, but the details are not important. I have also made a simple client using hyper's client module to send…
Misho Janev
  • 512
  • 5
  • 13
2
votes
2 answers

Creating a hyper service with custom error type

I am trying to create a REST server using hyper. For robust error handling, I would prefer to have the service return a future with a custom error type that wraps hyper, Diesel, and other errors. Unfortunately, hyper::Response seems to hard-code a…
Jason Watkins
  • 3,766
  • 1
  • 25
  • 39
2
votes
1 answer

Rust "expected identifier, found keyword" on importing

I have two files, loop.rs contains a function request to instantiate a client and get a body of a webpage. I want to export request to main. I know that to export I need to mod file_to_import and then use file_to_import::function_to_use according to…
zep
  • 271
  • 1
  • 3
  • 8
2
votes
1 answer

Request message value must be valid for the static lifetime

I want to implement a blocking function that sends a POST request with a JSON body and returns the JSON object of the response: extern crate tokio_core; extern crate rustc_serialize; extern crate hyper; extern crate futures; use std::str; use…
Federico
  • 1,925
  • 14
  • 19
2
votes
2 answers

Implement retry with Hyper HTTP Client

I'm trying to implement a retry in a client built with Hyper v0.11, but I can't find a way to reuse a request for different attempts: #[macro_use] extern crate hyper; extern crate futures; extern crate tokio_core; use futures::Future; use…
cspinetta
  • 443
  • 6
  • 17
2
votes
1 answer

Keeping cookie between transactions with Hyper

I would like to be able to keep the cookie of a previous request for the next one : let hyper_client = Client::new(); server_response = hyper_client.request(Method::Get, url).headers(Headers::new()).send(); Assuming the code above compile, how…
Le Duc Banal
  • 53
  • 11
2
votes
2 answers

Read gzip response with Hyper and Flate2

Hyper has the function fn read(&mut self, buf: &mut [u8]) -> io::Result to read the contents of an HTTP response into the provided &mut [u8]. Flate2 can gunzip: let mut d = GzDecoder::new("...".as_bytes()).unwrap(); let mut s =…
Synesso
  • 37,610
  • 35
  • 136
  • 207
2
votes
2 answers

Why does hyper require Handler to implement Sync instead of using independent Handlers per thread?

Hyper has the following example of a Handler that implements Sync: use std::sync::Mutex; use std::sync::mpsc::{channel, Sender}; use hyper::server::{Handler, Server, Request, Response}; struct SenderHandler { sender: Mutex
PureW
  • 4,568
  • 3
  • 19
  • 27
2
votes
1 answer

Unable to create hyper::Client because the compiler cannot infer enough type information

To experiment with Hyper, I started with the GET example. Aside the fact that the example doesn't compile (no method `get` in `client`) I have distilled my problem to a single line: fn temp() { let client = Client::new(); } This code won't…
Roman Smelyansky
  • 319
  • 1
  • 13
2
votes
1 answer

Using convert::Into with enum to unwrap and convert value

I'm starting to get comfortable with Rust, but there are still some things that are really tripping me up with lifetimes. In this particular case, what I want to do is have an enum which may have different types wrapped as a generic parameter class…
bluejekyll
  • 155
  • 2
  • 8
2
votes
1 answer

How can I set HTTP status code in hyper HTTP Server handler?

According to the documentation I could get mutable reference to the status by calling status_mut(). Unfortunately signature of the handler function, used to serve requests with hyper::Server contain immutable Response, so the following code gives me…
hoxnox
  • 355
  • 1
  • 4
  • 16