Skip to content

Instantly share code, notes, and snippets.

@e00E
Last active July 13, 2017 21:40
Show Gist options
  • Save e00E/4d684ed5726fef816a0ef6dac990ede0 to your computer and use it in GitHub Desktop.
Save e00E/4d684ed5726fef816a0ef6dac990ede0 to your computer and use it in GitHub Desktop.
[package]
name = "failrequest"
version = "0.1.0"
authors = ["e00E"]
[dependencies]
reqwest = "0.6"
extern crate reqwest;
const URL: &str = "https://httpbin.org/post";
// uncomment (and comment above) to test http instead of https
// const URL: &str = "http://httpbin.org/post";
fn test_with_files() {
// Create the files first with: for i in 1 10 50 100 200 1000; do dd if=/dev/zero of=${i}KB bs=${i}K count=1; done
let filenames = &["1KB", "10KB", "50KB", "100KB", "200KB", "1000KB"];
for filename in filenames {
println!("Uploading from file {}", filename);
//let client = reqwest::Client::builder().unwrap()
let mut client = reqwest::Client::new().unwrap();
client.gzip(false); // Does not actually change the outcome but I wanted to make sure the body is not altered
// Uncomment to test with Fiddler as proxy on windows
// .proxy(reqwest::Proxy::https("http://localhost:8888").unwrap())
let response = client.post(URL)
.body(std::fs::File::open(filename).unwrap())
.send().unwrap();
println!("{}", response.status());
}
}
fn main() {
// Usually fails starting at 100KB or 200KB on windows
// "fails" means the request "hangs" (it does not finish in the time it should) and
// after a while httpbin returns status code 499 likely because we did not correctly send the request
// Does not fail on windows when http instead of https is used for httpbin
// Does not fail on windows when Fiddler is used to intercept the https traffic
// Does not matter if run in release mode or not
//
// Does not fail on linux
test_with_files();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment