Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout silently truncates response body #49

Closed
tdryer opened this issue Jan 27, 2020 · 2 comments · Fixed by #50
Closed

Timeout silently truncates response body #49

tdryer opened this issue Jan 27, 2020 · 2 comments · Fixed by #50

Comments

@tdryer
Copy link
Contributor

tdryer commented Jan 27, 2020

Specifying timeout for a request appears to silently truncate the response body if it being received when the the timeout expires.

Example:

http://httpbin.org/drip will return 10 bytes over 2 seconds:

$ time curl "http://httpbin.org/drip"; echo
**********
real    0m2.005s

With a 1 second timeout, curl returns an error:

$ time curl -m 1 "http://httpbin.org/drip"; echo
curl: (28) Operation timed out after 1000 milliseconds with 4 out of 10 bytes received
****
real    0m1.008s

This is an attohttpc program that I expected do the same thing:

use std::time::Duration;

use attohttpc::Result;

fn main() -> Result {
    let resp = attohttpc::get("http://httpbin.org/drip")
        .timeout(Duration::from_secs(1))
        .send()?;
    println!("Status: {:?}", resp.status());
    println!("Body:\n{}", resp.text()?);
    Ok(())
}

But instead of returning an error, the result is successful, and text is truncated:

$ time cargo run --example drip
Status: 200
Body:
*****

real    0m1.178s
@adamreichold
Copy link
Contributor

Output when running the above MR:

Status: 200
Error: Error(Io(Kind(TimedOut)))

@sbstp sbstp closed this as completed in #50 Jan 29, 2020
@tdryer
Copy link
Contributor Author

tdryer commented Jan 29, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants