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

Connection: close on request that uses Transfer-Encoding: chunked on the response does not read full response #547

Closed
wezm opened this issue May 25, 2015 · 2 comments

Comments

@wezm
Copy link

wezm commented May 25, 2015

Sample program that reads entire response:

extern crate hyper;
extern crate env_logger;

use std::io::Read;

use hyper::Client;
use hyper::header::Connection;

fn main() {
    env_logger::init().unwrap();

    // Create a client.
    let mut client = Client::new();

    // Creating an outgoing request.
    let mut res = client.get("http://promodj.com/taga/rss.xml")
        // set a header
        // .header(Connection::close())
        // let 'er go!
        .send().unwrap();

    // Read the Response.
    let mut body = String::new();
    res.read_to_string(&mut body).unwrap();

    println!("Response: {}", body);
}

Running this gives the following trace: https://gist.github.com/wezm/962eb2c7b16b908256f3

Uncommenting the Connection::close line gives the following: https://gist.github.com/wezm/3942e9d33add01c789a2

I'm not sure if this is bug in hyper or the server misbehaving (I don't control the server). I note that curl downloads the full response even when the Connection: close header is specified via -H "Connection: close".

@wezm
Copy link
Author

wezm commented May 25, 2015

I tracked down the problem and have come up with this as a fix but I'm new to Rust and this project so you may have a better approach: wezm@4a42f43

@seanmonstar
Copy link
Member

Sorry about that, I had merged a fix into master already, but haven't published a new version yet. I'll do that right away.

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

No branches or pull requests

2 participants