DEV Community

Cover image for usecase of httpie / httpie使用
Z. QIU
Z. QIU

Posted on • Edited on

2 1

usecase of httpie / httpie使用

Earlier this year, I have managed the development of a WebApp for industrial supplychain sourcing in our start-up . It's a typical B/S-architecture project whose server side was entirely developed by myself (Ubuntu running over AliCloud + Django + Neo4j + MongoDB + Docker + Tomcat + nginx + other dependences).

Alt Text

Below are some notes about a simple tool called httpie that I used for testing my APIs. These notes were taken in Chinese, however I add also simple translation in English in case someone happens to read this post and wants to understand it.

可以使用pip安装(installing using pip with a specified source):

 pip install --upgrade httpie -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
Enter fullscreen mode Exit fullscreen mode

测试get请求(testing a GET request):

    http -v GET http://127.0.0.1:8000/suppliers_server/get_user?username=qiu
Enter fullscreen mode Exit fullscreen mode

测试POST带表单请求(testing a POST request):

 http --form POST http://127.0.0.1:8000/suppliers_server/query_login username="qiu" password="123456"
Enter fullscreen mode Exit fullscreen mode

测试get请求带cookie(testing a GET request containing cookie):

http -v GET http://127.0.0.1:8000/corporadb/login  Cookie:sessionid=vc1d2m5kb1zul63l9g24qq5w58vfj35g
Enter fullscreen mode Exit fullscreen mode

将token包含在header中(testing a GET request containing token):

http -v GET http://127.0.0.1:8000/suppliers_server/query_chain?product=cd Cookie:sessionid=y4nokqeymk54tdapicjjkmbve1qfuheo Authorization:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InFpdSJ9.qLDaly37vl77SxyHNPEqq6_HKzbSinmPcG9GvGQ-JdQ
Enter fullscreen mode Exit fullscreen mode

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay