lipanski / mockito

HTTP mocking for Rust!
MIT License
695 stars 59 forks source link

Support streaming body #176

Closed kornelski closed 1 year ago

kornelski commented 1 year ago

Fixes #175

lipanski commented 1 year ago

Thank you! :1st_place_medal:

Released as 1.1.1

Daanoz commented 1 year ago

Leaving this here in case someone runs into the same issue as me. I was using (maybe abusing) with_chunked_body to simulate connection timeouts:

            .with_chunked_body(|w| {
                std::thread::sleep(std::time::Duration::from_millis(500));
                w.write_all(b"data")
            })

This no longer works due to this change, the connection is immediately accepted before even sending data. Changed it to with_body_from_request to have a similar behavior as before:

            .with_body_from_request(|_| {
                std::thread::sleep(std::time::Duration::from_millis(500));
                b"data".to_vec()
            })