-
Notifications
You must be signed in to change notification settings - Fork 98
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
add support for HTTPie's --raw flag #202
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9b7fcbf
add support for --raw flag
ducaale e397720
add tests for --raw
ducaale fdc69ae
update README.md
ducaale 44465c9
mention that Multipart bodies are never "empty"
ducaale 1e7e53c
no matching on negated booleans
ducaale 1ed884f
raw bodies should never be empty
ducaale 16f4bd5
add tests for default method, --raw and stdin
ducaale 24f4704
Avoid unnecessary copy
ducaale 30c60ed
pipe binary data directly in tests
ducaale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -1350,6 +1350,30 @@ fn mixed_stdin_request_items() { | |
)); | ||
} | ||
|
||
#[test] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also test successful use of the option? |
||
fn mixed_stdin_raw() { | ||
let input_file = tempfile().unwrap(); | ||
redirecting_command() | ||
.args(&["--offline", "--raw=hello", ":"]) | ||
.stdin(input_file) | ||
.assert() | ||
.failure() | ||
.stderr(contains( | ||
"Request body from stdin and --raw cannot be mixed", | ||
)); | ||
} | ||
|
||
#[test] | ||
fn mixed_raw_request_items() { | ||
get_command() | ||
.args(&["--offline", "--raw=hello", ":", "x=3"]) | ||
.assert() | ||
.failure() | ||
.stderr(contains( | ||
"Request body (from --raw) and request data (key=value) cannot be mixed", | ||
)); | ||
} | ||
|
||
#[test] | ||
fn multipart_stdin() { | ||
let input_file = tempfile().unwrap(); | ||
|
@@ -1361,6 +1385,15 @@ fn multipart_stdin() { | |
.stderr(contains("Cannot build a multipart request body from stdin")); | ||
} | ||
|
||
#[test] | ||
fn multipart_raw() { | ||
get_command() | ||
.args(&["--offline", "--raw=hello", "--multipart", ":"]) | ||
.assert() | ||
.failure() | ||
.stderr(contains("Cannot build a multipart request body from --raw")); | ||
} | ||
|
||
#[test] | ||
fn default_json_for_raw_body() { | ||
let server = server::http(|req| async move { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find matching on negated booleans hard to follow.
Maybe it would be better to turn
ignore_stdin
intolet use_stdin = !(args.ignore_stdin || atty::is(Stream::Stdin) || test_pretend_term());
? And perhapslet has_request_items = !body_from_request_items.is_empty();
.