-
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
Conversation
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.
Works great!
It's not caused by this change, but I just noticed that HTTPie doesn't use a POST request for a zero-length body, e.g. printf '' | xh --offline :
. I don't know how straightforward that'll be to fix, so we could make an issue for it instead.
src/main.rs
Outdated
if body.is_multipart() { | ||
let body_from_request_items = args.request_items.body()?; | ||
|
||
let body = match (!ignore_stdin, args.raw, !body_from_request_items.is_empty()) { |
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
into let use_stdin = !(args.ignore_stdin || atty::is(Stream::Stdin) || test_pretend_term());
? And perhaps let has_request_items = !body_from_request_items.is_empty();
.
@@ -1350,6 +1350,30 @@ fn mixed_stdin_request_items() { | |||
)); | |||
} | |||
|
|||
#[test] |
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.
Can you also test successful use of the option?
Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
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.
Looks great!
tests/cli.rs
Outdated
binary_file.write_all(b"foo\0bar").unwrap(); | ||
binary_file.seek(SeekFrom::Start(0)).unwrap(); | ||
redirecting_command() | ||
.args(&["--print=B", "--offline", ":"]) | ||
.stdin(binary_file) | ||
.pipe_stdin(binary_file.path()) |
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.
Would .write_stdin(b"foo\0bar")
work?
Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
Resolves #178