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

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay