httpie

18,014 views

Published on

These are slides from a "mini-talk" (~15 minutes) I recently gave on httpie.

Published in: Technology, Design
0 Comments
20 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
18,014
On SlideShare
0
From Embeds
0
Number of Embeds
10,739
Actions
Shares
0
Downloads
45
Comments
0
Likes
20
Embeds 0
No embeds

No notes for slide

httpie

  1. 1. Scott Leberknight
  2. 2. "HTTPie: a CLI, cURL-like tool for humans" - httpie.org
  3. 3. "HTTPie is a command line HTTP client. Its goal is to make CLI interaction with web services as human-friendly as possible." - httpie.org
  4. 4. Implemented in Python Provides simple http command Colorized, formatted output
  5. 5. pip install --upgrade httpie Installation or easy_install httpie or yum install httpie (etc.)
  6. 6. Major Features colorized output output formatting query/form parameters security (auth, https) headers form file uploads persistent sessions supports all HTTP verbs wget-style downloads streamed responses
  7. 7. Usage http [flags] [METHOD] URL [REQUEST ITEMS]
  8. 8. 3 cool sites to test with: requestb.in example.org httpbin.org
  9. 9. Let's try it...
  10. 10. Hello World http httpie.org
  11. 11. -v (verbose)
  12. 12. Defaults... method - GET scheme - http:// data fields - JSON
  13. 13. Request Headers http requestb.in/vnm6qyvn Accept:application/json X-Test-Header:'Foo, Bar' Name:Value
  14. 14. URL parameters name==value http requestb.in/vnm6qyvn search=='curl vs. httpie' page==2
  15. 15. Data Fields (JSON) field=value field=@file.txt http requestb.in/vnm6qyvn search='curl vs. httpie' page=2
  16. 16. ...httpie will set the method to POST when a request contains data fields...
  17. 17. Data Fields (from a file) http requestb.in/vnm6qyvn data=@/Users/sleberkn/w.txt
  18. 18. Data Fields (form) -f, --form field=value field=@file.txt http --form requestb.in/vnm6qyvn search='curl vs. httpie' page=2
  19. 19. ...httpie will set the content type to application/x-www-form-urlencoded when you use --form ( or -f )...
  20. 20. Raw JSON field:=value field:=@file.txt http requestb.in/vnm6qyvn terms:='["curl", "vs.", "httpie"]' page:=2
  21. 21. File Uploads field@/dir/file_name http requestb.in/vnm6qyvn the_file@/Users/sleberkn/w.txt
  22. 22. ...httpie will set the content type to multipart/form-data when you do a file upload...
  23. 23. Easy as httpie!
  24. 24. HTTP Methods GET POST PUT PATCH DELETE HEAD (and a few more obscure ones...)
  25. 25. Testing methods with httpbin.org http GET httpbin.org/get http POST httpbin.org/post foo=bar http PUT httpbin.org/put foo=bar http PATCH httpbin.org/patch foo=bar http -f DELETE httpbin.org/delete
  26. 26. Authentication BASIC (default) or Digest -a,--auth --auth-type Has plugins for OAuth & others
  27. 27. Username & password
  28. 28. Username & password prompt
  29. 29. Downloads -d,--download -o,--output http -d -o out.txt httpbin.org/get
  30. 30. Persistent Sessions Custom headers, authorization, and cookies persist between requests to the same host Named & anonymous sessions
  31. 31. http --session=user1 -a user1:secret example.org X-Thingy:Foo http --session=user2 -a user2:monkey example.org Named Sessions
  32. 32. Other stuff... HTTPS support Supports proxies Redirect to/from http Control output via flags (--headers, --body, --print, etc.) JSON config file Scripting support (via --check-status) Streaming responses
  33. 33. httpie web site: httpie.org (redirects to https://github.com/jkbr/httpie ) References httpbin HTTP request & response service: httpbin.org RequestBin: requestb.in
  34. 34. My Info twitter: sleberknight www.sleberknight.com/blog scott dot leberknight at gmail.com

×