Expand description
Iron middleware that makes sure requests are read in full before reusing sockets
Hyper keeps sockets alive to reuse them between requests, to speed things up. If a request that isn’t supposed to have a body is sent with one, or if the server does not read out the full body of a request, then the next request will be corrupted due to data remaining in the network buffer.
The Drain
adapter in this module defines an iron AfterMiddleware
that makes sure to empty
the buffer before the next request, whether the current request succeeded or failed. It reads
up to a configurable limit, and if there is still more data remaining, it closes the socket.
Usage:
extern crate iron;
extern crate iron_drain;
use iron::prelude::*;
use iron::status;
use iron_drain::Drain;
let mut srv = Chain::new(|_: &mut Request| {
Ok(Response::with((status::Ok, "Hello world!")))
});
srv.link_after(Drain::new());
Iron::new(srv).http("localhost:3000").unwrap();
Structs§
- Drain
- Iron middleware that makes sure requests are read in full before reusing sockets