AkamaiOPEN-edgegrid-python icon indicating copy to clipboard operation
AkamaiOPEN-edgegrid-python copied to clipboard

Errors while streaming uploads (HTTPie 2.3.0)

Open javiergarza opened this issue 4 years ago • 2 comments

The latest version of HTTPie (v2.3.0) fails when making POST request using the Edgegrid authentication plugin which uses https://github.com/akamai/AkamaiOPEN-edgegrid-python to make the underlaying calls.

I enabled debugging and tracked the failure to the Edgegrid python library (edgegrid.py line 146)

Here is a command I used to reproduce the issue: $ http --verbose -A edgegrid --debug -a devrel-all: POST :/config-dns/v2/zones/akamaideveloper.net/zone-file Content-Type:text/dns < akamaideveloper.net.zone

Here are the last few lines of the error output that point to the issue:

  File "/Users/jgarza/.pyenv/versions/3.8.0/lib/python3.8/site-packages/akamai/edgegrid/edgegrid.py", line 147, in make_content_hash
    if r.method == 'POST' and len(prepared_body) > 0:
TypeError: object of type '_io.BufferedReader' has no len()

I suspect the new version of HTTPie streams the uploads, and therefore the prepared_body has no length when evaluated (it is possible this may affect other CLI tools that leverage this library that try to stream uploads).

javiergarza avatar Nov 06 '20 22:11 javiergarza

Workaround: you can use the shell pipe to redirect the terminal input to HTTPie like this:

$ cat akamaideveloper.net.zone | http --verbose -A edgegrid -a devrel-all: POST :/config-dns/v2/zones/akamaideveloper.net/zone-file Content-Type:text/dns

javiergarza avatar Dec 08 '20 17:12 javiergarza

as a workaround instead of httpie install httpie==2.2.0

DmitriyStoyanov avatar Dec 18 '20 09:12 DmitriyStoyanov

Hello @javiergarza Thank You for opening the issue. On most recent version of HTTPie (3.2.1) and most recent version of httpie-edgegrid (2.1.1) the issue seems to not occur anymore as it's possible to send successfully POST. Therefor I'll close this issue. If it still occurs for Your case on mentioned above versions (or newer in the future), please open new issue or reopen this one.

Best regards, Wojciech

wzagrajcz avatar Feb 10 '23 14:02 wzagrajcz