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

Binary content no longer showing in terminal. #2325

Closed
wants to merge 2 commits into from

Conversation

bogdiw
Copy link

@bogdiw bogdiw commented Jan 13, 2024

Solves #2306

Added an additional check to see if the output is binary. If so, an error message is printed.

Copy link

@asggWa asggWa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fantastico. tendremos que testearlo. gracias.

@fabricereix
Copy link
Collaborator

Thanks @bogdiw for your PR.
First, you can check the Contributing guide to sign your commits and run the integration tests.

Then, the behaviour in Hurl needs to be consistent with curl:

  • the warnings only applies when outputing to a terminal
  • output can still written with --output option
    ...

I'm going first to implement (#2312) as a prerequisite for your PR.

@bogdiw
Copy link
Author

bogdiw commented Jan 14, 2024

I've solved the cargo clippy errors, but the /tests_ok/assert_base64.py it's failing. Any advice in handling this? Maybe adding the test to /tests_failed should change it because now we don't print binary on screen anymore.

@fabricereix
Copy link
Collaborator

This test must clearly pass.
You can always double check with curl:

$ curl 'http://localhost:8000/assert-base64'
line1
line2
line3 

@bogdiw
Copy link
Author

bogdiw commented Jan 15, 2024

Ok, thank you. I'll try to fix the code then.

@jcamiel
Copy link
Collaborator

jcamiel commented Jan 15, 2024

Hi @bogdiw the code doesn't seem OK to me:

let is_binary = response.body.iter().any(|&byte| !(32..=126).contains(&byte));

I don't understand why this condition is linked to the output being binary and doesn't seem correct to me. Could you explain it?

@bogdiw
Copy link
Author

bogdiw commented Jan 15, 2024

Hi @jcamiel my main idea was to check whether any byte in the response body is outside the ASCII range of printable characters (32 to 126).

@jcamiel
Copy link
Collaborator

jcamiel commented Jan 15, 2024

I think we can have false positive doing this.
We should try to see how curl is doing it. In the proposed PR, I see another problem: we don't want to check every byte for a big file for instance (testing if a 1GB text file is binary would imply testing every bytes).

Copy link

@jdicke jdicke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@hurl-bot
Copy link
Collaborator

hurl-bot commented Mar 4, 2024

📆 This PR has been closed because there is no activity (commits/comments) for more than 15 days 😥. Feel free to reopen it with new commits/comments.

@hurl-bot hurl-bot closed this Mar 4, 2024
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

Successfully merging this pull request may close these issues.

None yet

6 participants