-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow use of Expect header to be configured (#340)
Add a configuration option for changing how POST requests behave under HTTP/1.1 and the `Expect: 100-continue` request behavior. Allow the user to change the timeout to a different duration or to disable the header entirely. Replaces #311. Fixes #303.
- Loading branch information
Showing
4 changed files
with
198 additions
and
3 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 @@ | ||
use isahc::{Body, Request, prelude::*}; | ||
use testserver::mock; | ||
|
||
#[test] | ||
fn expect_header_is_sent_by_default() { | ||
let m = mock!(); | ||
|
||
let body = Body::from_reader("hello world".as_bytes()); | ||
|
||
isahc::post(m.url(), body).unwrap(); | ||
|
||
m.request().expect_header("expect", "100-continue"); | ||
} | ||
|
||
#[test] | ||
fn expect_header_is_not_sent_when_disabled() { | ||
let m = mock!(); | ||
|
||
let body = Body::from_reader("hello world".as_bytes()); | ||
|
||
Request::post(m.url()) | ||
.expect_continue(false) | ||
.body(body) | ||
.unwrap() | ||
.send() | ||
.unwrap(); | ||
|
||
assert!(m.request().get_header("expect").next().is_none()); | ||
} |