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

Incorrectly issues a GET request instead of POST when given a valid --session #364

Closed
raphaelh opened this issue Jun 25, 2015 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@raphaelh
Copy link

When the session file exists, httpie issues a GET request even though it was told to issue a POST:

$ http --pretty=all --verbose --session="$SESSIONFILE" --follow --form POST "$BASEURL" _token="$TOKEN" _task="login" _action="login" _user="$USER" _pass="$PASS"
GET /roundcube/?_task=mail HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Cookie: roundcube_sessid=hr9nh5kh898l8p96o9l4q2gdq4; roundcube_sessid=o41hfqjhsg1coe84vpnnpn7415; roundcube_sessauth=S45bd81346b5fadf9c8e43669cd32fa957611783f
Host: demo.linuxsolutions.com.br
User-Agent: HTTPie/0.8.0

When the session file doesn't exist (notice xx at the end of --session="$SESSIONFILE"), httpie correctly issues a POST request:

$ http --pretty=all --verbose --session="$SESSIONFILE"xx --follow --form POST "$BASEURL" _token="$TOKEN" _task="login" _action="login" _user="$USER" _pass="$PASS"
POST /roundcube/ HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Content-Length: 117
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: demo.linuxsolutions.com.br
User-Agent: HTTPie/0.8.0

_token=f5a7c5fdb3e95d4686606402a1998883&_task=login&_action=login&_user=demo%40linuxsolutions.com.br&_pass=%23demo%24

You can find the full script here: https://github.com/raphaelh/roundcube_scripts/blob/master/rc_unread_httpie.sh

@jkbrzt
Copy link
Member

jkbrzt commented Jun 26, 2015

I'm unable to reproduce this. Could you provide a minimal example?

$ http -v --session=issue364 httpbin.org/post foo=bar | grep POST
POST /post HTTP/1.1
$ http -v --session=issue364 httpbin.org/post foo=bar | grep POST
POST /post HTTP/1.1

@jkbrzt jkbrzt added bug Something isn't working needs input labels Jun 26, 2015
@raphaelh
Copy link
Author

Try this script: https://gist.github.com/raphaelh/3b65bd16fb6e2662e412

Run it several times, it will alternatively issue GET and POST

@jkbrzt
Copy link
Member

jkbrzt commented Jun 30, 2015

When you remove --follow from the command, you get POST every time. It's because currently, only the last request/response is output when a redirect is --followed. A limitation that should be fixed soon.

@raphaelh
Copy link
Author

raphaelh commented Jul 1, 2015

Thanks for your quick reply. So is there a workaround at the moment?

@raphaelh
Copy link
Author

Any update on this issue?

@jkbrzt
Copy link
Member

jkbrzt commented Feb 29, 2016

@raphaelh the current master has a new --show-redirects option

@jkbrzt jkbrzt closed this as completed Feb 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants