Skip to content

Instantly share code, notes, and snippets.

@kindlycat
Created July 19, 2017 19:30
Show Gist options
  • Save kindlycat/30d41e911c1430aa6623e00e58e5edf0 to your computer and use it in GitHub Desktop.
Save kindlycat/30d41e911c1430aa6623e00e58e5edf0 to your computer and use it in GitHub Desktop.
Useful things for work with httpie
# 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