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

Add --all flag for printing intermediate requests and responses #137

Merged
merged 50 commits into from
Sep 3, 2021

Conversation

ducaale
Copy link
Owner

@ducaale ducaale commented May 5, 2021

Also adds the history_print flag for customizing printed sections for intermediate requests only.

Ticks another item from #4.

@ducaale ducaale changed the title Support printing intermediate requests and responses when redirecting Add --all flag for printing intermediate requests and responses May 12, 2021
@ducaale ducaale marked this pull request as ready for review May 12, 2021 21:39
src/redirect.rs Outdated Show resolved Hide resolved
@ducaale ducaale requested a review from blyxxyz May 13, 2021 22:19
@ducaale
Copy link
Owner Author

ducaale commented May 22, 2021

But it doesn't seem to match HTTPie yet. http --follow --print=HhBb httpbin.org/status/302 prints all the request bodies and only the final response body.

That sounds really unintuitive. Do you know why it ignores intermediate responses in this case?

ducaale and others added 2 commits May 22, 2021 18:28
Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
src/main.rs Outdated Show resolved Hide resolved
this is to avoid confusion with http redirect
@blyxxyz
Copy link
Collaborator

blyxxyz commented Jun 1, 2021

Do you know why it ignores intermediate responses in this case?

That's what --all is for. The weird thing is that it does print all requests even without --all.

I think we should file an issue with HTTPie for clarification to fix either the implementation or the documentation.

This was referenced Jun 29, 2021
Copy link
Collaborator

@blyxxyz blyxxyz left a comment

Choose a reason for hiding this comment

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

From experimenting and digging around HTTPie's source code I think its --history-print is unused. Or maybe I'm missing something.


Printing the first request and last response by default seems reasonable to go with for now.

src/main.rs Show resolved Hide resolved
Base automatically changed from sessions to develop August 5, 2021 15:56
Copy link
Collaborator

@blyxxyz blyxxyz left a comment

Choose a reason for hiding this comment

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

Two tiny nitpicks, but I'm also ok with ignoring them.

src/main.rs Outdated Show resolved Hide resolved
client.on_redirect(|prev_response, next_request| {
printer.print_response_headers(&prev_response)?;
printer.print_response_body(prev_response)?;
printer.print_seperator()?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

HTTPie doesn't have exactly this logic, http -v --print= --follow httpbin.org/status/302 has zero lines of output. (I haven't checked which logic it does use.)

Copy link
Owner Author

@ducaale ducaale Sep 3, 2021

Choose a reason for hiding this comment

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

I will look into this in a separate PR as I have a feeling that the fix will be a little bit more involved.

@ducaale ducaale merged commit 560b004 into develop Sep 3, 2021
@ducaale ducaale deleted the all-flag branch September 3, 2021 18:03
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.

2 participants