forked from tiny-http/tiny-http
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Vec size based on Content-Length header
fixes issue tiny-http#252
- Loading branch information
Showing
4 changed files
with
90 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#![cfg(unix)] | ||
|
||
use std::io::Write; | ||
|
||
extern crate tiny_http; | ||
|
||
#[allow(dead_code)] | ||
mod support; | ||
|
||
#[test] | ||
fn test_equal_reader_drop_rlimit() { | ||
// this limits need to be fiddled out, because test runs need a lot more memory than the productive server | ||
rlimit::Resource::AS | ||
.set(90_000_000, 90_000_000) | ||
.expect("ulimit -v 90_000_000 failed"); | ||
|
||
let (server, client) = support::new_one_server_one_client(); | ||
|
||
{ | ||
let mut client = client; | ||
(write!(client, "GET / HTTP/1.1\r\nHost: localhost\r\nContent-Type: text/plain; charset=utf8\r\nContent-Length: 104857600\r\n\r\nhello")).unwrap(); | ||
} | ||
|
||
let mut request = server.recv().unwrap(); | ||
|
||
let mut output = String::new(); | ||
request.as_reader().read_to_string(&mut output).unwrap(); | ||
assert_eq!(output, "hello"); | ||
} |