Merge pull request #401 from hyperium/packets

fix(http): read more before triggering TooLargeError
This commit is contained in:
Sean McArthur
2015-03-28 11:37:43 -07:00
6 changed files with 189 additions and 43 deletions

View File

@@ -1,5 +1,5 @@
//! HTTP Server
use std::io::{BufReader, BufWriter, Write};
use std::io::{BufWriter, Write};
use std::marker::PhantomData;
use std::net::{SocketAddr, ToSocketAddrs};
use std::path::Path;
@@ -14,6 +14,7 @@ pub use net::{Fresh, Streaming};
use HttpError::HttpIoError;
use {HttpResult};
use buffer::BufReader;
use header::{Headers, Connection, Expect};
use header::ConnectionOption::{Close, KeepAlive};
use method::Method;
@@ -227,6 +228,7 @@ mod tests {
Host: example.domain\r\n\
Expect: 100-continue\r\n\
Content-Length: 10\r\n\
Connection: close\r\n\
\r\n\
1234567890\
");

View File

@@ -2,10 +2,11 @@
//!
//! These are requests that a `hyper::Server` receives, and include its method,
//! target URI, headers, and message body.
use std::io::{self, Read, BufReader};
use std::io::{self, Read};
use std::net::SocketAddr;
use {HttpResult};
use buffer::BufReader;
use net::NetworkStream;
use version::{HttpVersion};
use method::Method::{self, Get, Head};
@@ -81,12 +82,13 @@ impl<'a, 'b> Read for Request<'a, 'b> {
#[cfg(test)]
mod tests {
use buffer::BufReader;
use header::{Host, TransferEncoding, Encoding};
use net::NetworkStream;
use mock::MockStream;
use super::Request;
use std::io::{self, Read, BufReader};
use std::io::{self, Read};
use std::net::SocketAddr;
fn sock(s: &str) -> SocketAddr {