okigan / awscurl

curl-like access to AWS resources with AWS Signature Version 4 request signing.
MIT License
737 stars 91 forks source link

Some --verbose text printed to stdout #142

Open mielliott opened 2 years ago

mielliott commented 2 years ago

Here's the output for sending a request to google.com:

$ awscurl http://google.com 2> /dev/null
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

Then add the verbose flag but suppress stderr:

$ awscurl -v http://google.com 2> /dev/null
{'Location': 'http://www.google.com/', 'Content-Type': 'text/html; charset=UTF-8', 'Date': 'Thu, 03 Mar 2022 15:13:27 GMT', 'Expires': 'Sat, 02 Apr 2022 15:13:27 GMT', 'Cache-Control': 'public, max-age=2592000', 'Server': 'gws', 'Content-Length': '219', 'X-XSS-Protection': '0', 'X-Frame-Options': 'SAMEORIGIN'}

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

Looks like the response headers are being printed to stdout instead of stderr (where all the other verbose text is sent).

PS - thanks for this tool! As you might be aware, new versions of curl add an --aws-sig4 option to handle signing for AWS requests, but I've been unable to get it working for some specific API calls. awscurl has been working much more consistently :)

mielliott commented 2 years ago

Ah, I see:

https://github.com/okigan/awscurl/blob/ea2a9b192e80053a4edf7dbfe7b390e249a92527/awscurl/awscurl.py#L511-L512

This is different from curl, where -i and -v do not overlap: -i prints response headers to stdout, whereas -v prints response headers (and everything else) to stderr. This separation can be very useful

okigan commented 2 years ago

Interesting - I’ll have a look!

On Mar 3, 2022, at 8:19 AM, Michael Elliott @.***> wrote:

 Ah, I see:

https://github.com/okigan/awscurl/blob/ea2a9b192e80053a4edf7dbfe7b390e249a92527/awscurl/awscurl.py#L511

With curl, -i and -v do not overlap: -i prints response headers to stdout, whereas -v prints response headers (and everything else) to stderr

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you are subscribed to this thread.