okigan / awscurl

curl-like access to AWS resources with AWS Signature Version 4 request signing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some --verbose text printed to stdout

mielliott opened this issue · comments

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 :)

Ah, I see:

awscurl/awscurl/awscurl.py

Lines 511 to 512 in ea2a9b1

if args.include or IS_VERBOSE:
print(response.headers, end='\n\n')

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