Created
July 19, 2017 19:30
-
-
Save kindlycat/30d41e911c1430aa6623e00e58e5edf0 to your computer and use it in GitHub Desktop.
Useful things for work with httpie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this to .bashrc or .zshrc | |
# Alias for use session with current virtualenv's name or "default". | |
alias http='http --session=$(basename ${VIRTUAL_ENV:-default})' | |
# Add header for ajax requests. | |
httpx() { | |
http $* X-Requested-With:XMLHttpRequest | |
} | |
# Function for login. Get csrf token from header. | |
function httpl() { | |
csrf=`http $1 -h | grep -Po '(?<=csrftoken=)[^;]*(?=;)'` | |
http -f POST $* X-CsrfToken:$csrf | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment