Giter VIP home page Giter VIP logo

dotnet-httpie's Introduction

dotnet-HTTPie

dotnet-HTTPie

dotnet-HTTPie Latest

Github Actions Build Status

Docker Pulls

Intro

dotnet tool version of httpie, Modern, user-friendly command-line HTTP client for the API era.

httpie

HTTPie (pronounced aitch-tee-tee-pie) is a command-line HTTP client. Its goal is to make CLI interaction with web services as human-friendly as possible. HTTPie is designed for testing, debugging, and generally interacting with APIs & HTTP servers.

Install

Install .NET SDK before you get started with this tool, when you had .NET SDK installed, run the command below to install the latest stable version tool

dotnet tool update --global dotnet-httpie

For latest preview version, run the following command instead:

dotnet tool update --global dotnet-httpie --prerelease

GetStarted

Now you can use the tool to call your API you want

Usages:

dotnet-http [flags] [METHOD] URL [ITEM [ITEM]]

There're three types of item

Type Grammar
Query name==test
Header X-Api-Key:test
Request-Data name=test, raw data field example(Only effective for JSON): age:=10, job:='{"Id":1,"Name":"test"}'(Escape may needed for Windows cmd or Windows PowerShell)

Here's a sample:

dotnet-http https://reservation.weihanli.xyz/health test==1234 name=test age:=10 flag:=true job:='{"id": 1, "name": "test"}' api-key:Abc12345 --offline

sample

More examples you may wanna have a look

dotnet-http :5000/api/values
dotnet-http localhost:5000/api/values
dotnet-http get https://reservation.weihanli.xyz/api/notice --body
dotnet-http /api/notice title=test body=test-body
dotnet-http post http://localhost/api/notice title=test body=test-body

Execute

You can execute *.http/*.rest http requests with the exec command

dotnet-http exec HttpStartedSample.http

dotnet-http exec ".\tests\HTTPie.IntegrationTest\TestAssets\HttpStartedSample.http"
dotnet-http exec ".\tests\HTTPie.IntegrationTest\TestAssets\HttpVariableSample.http"
dotnet-http exec ".\tests\HTTPie.IntegrationTest\TestAssets\HttpRequestReferenceSample.http"

see http request sample here: https://github.com/WeihanLi/dotnet-httpie/tree/dev/tests/HTTPie.IntegrationTest/TestAssets

Docker

There's a docker image(weihanli/dotnet-httpie) that you could use directly without installing the tool, use sample:

docker run --rm --pull=always weihanli/dotnet-httpie:latest http -v github.com

docker run --rm --pull=always weihanli/dotnet-httpie:latest http reservation.weihanli.xyz/health job:='{"id":1,"name":"tester"}' --offline

docker run --rm --pull=always weihanli/dotnet-httpie:latest http PUT httpbin.org hello=world

docker run --rm --pull=always weihanli/dotnet-httpie:latest http get httpbin.org/status/400

More

For detailed document: have a look at HTTPie documents https://httpie.io/docs#examples

References

dotnet-httpie's People

Contributors

weihanli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

watch-later xkrof

dotnet-httpie's Issues

Load test exporter

Support for load test exporter to export load test result to different output

  • json
  • influxdb
  • ...

Unexpected header attach

Describe the bug

 dotnet-http https://auth.docker.io/token X-Docker-Token:true service==registry.docker.io scope=="repository:weihanli/mdni
ce:pull" -v
GET /token?service=registry.docker.io&scope=repository:weihanli/mdnice:pull HTTP/1.1
Host: auth.docker.io
Schema: https
scope==repository: weihanli/mdnice:pull
User-Agent: dotnet-HTTPie/0.6.1
X-Docker-Token: true
X-dotnet-HTTPie-RequestTimestamp: 10/16/2022 11:06:53 +08:00                                                                                                                                                                                                                            HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sun, 16 Oct 2022 03:06:54 GMT
Strict-Transport-Security: max-age=31536000
Transfer-Encoding: chunked
X-dotnet-HTTPie-Duration: 1607.883ms
X-dotnet-HTTPie-ResponseTimestamp: 10/16/2022 11:06:54 +08:00
x-trace-id: 2ff2273a606f8514030862a3ac9c3bfd

Header not attached

Describe the bug

Header not attached

To Reproduce

dotnet-http -v "http://localhost:6200/api/Calculation/V1/OrderSubscribe/preview" Pref:'{"crs":0,"ctc":"KR","crc":"KRW","lac":"zh-CN","storeid":0,"som":"kilograms"}' --offline

Expected behavior

Pref header should be attached

Screenshots

image

Additional context

version: 0.5.1

Scripting support

Is your feature request related to a problem? Please describe.

scripting support likes postman scripts

Execute subcommand

Add execute subcommand

http #64

# execute http request
dotnet-http exec demo.http

curl #51

dotnet-http exec `curl text` -t curl

Har support #52

dotnet-http exec xx.har --type har

Proxy support

Is your feature request related to a problem? Please describe.

Send requests with a proxy

`-h` bug

Describe the bug

image

To Reproduce

dotnet-http -h

Expected behavior

Output the helps info

Load test support

Is your feature request related to a problem? Please describe.

Load test feature, iteration, concurrent use etc ...

P90, P95, etc

Input

  • Iteration
  • Duration
  • Virtual users

Output

  • Total requests
  • Success/fail requests
  • request per seconds
  • duration average/P99/P95/P90/P50

Additional context

  • AB
  • k6

Named Session support

See details https://httpie.io/docs#named-sessions

Usage examples:

# Create session named user1
http --session=user1 -a user1:password pie.dev/get X-Foo:Bar

# Refer to the session by its name 
http --session=user1 pie.dev/get

# To create or reuse a different session, simple specify a different name
http --session=user2 -a user2:password pie.dev/get X-Bar:Foo

download checksum validate

add support for validating the checksum hash value

new options

  • checksum
  • checksum-alg(md5/sha1/sha128/sha256...)

Nested JSON support

Is your feature request related to a problem? Please describe.

It would help us use complex json more easily

http pie.dev/post \
  platform[name]=HTTPie \
  platform[about][mission]='Make APIs simple and intuitive' \
  platform[about][homepage]=httpie.io \
  platform[about][homepage]=httpie.io \
  platform[about][stars]:=54000 \
  platform[apps][]=Terminal \
  platform[apps][]=Desktop \
  platform[apps][]=Web \
  platform[apps][]=Mobile
{
    "platform": {
        "name": "HTTPie",
        "about": {
            "mission": "Make APIs simple and intuitive",
            "homepage": "httpie.io",
            "stars": 54000
        },
        "apps": [
            "Terminal",
            "Desktop",
            "Web",
            "Mobile"
        ]
    }
}

Additional context

https://httpie.io/docs/cli/nested-json

http API test support

Testing spec

  • environment
  • collection(request collection)
  • group(request group in a collection)
  • request(specific request)
  • variable
collectionName: testCollection
  variables:
    - name: value

  - groupName: testGroup
      variables:
        - name: value
      - requestName: hello request
        variables:
          - name: value      
        assertion: "$response.EnsureSuccessStatusCode()"

Invalid request when the authorization header end with `==`

Describe the bug

Invalid request when the authorization header end with ==

To Reproduce

> dotnet-http :5000/api/values Authorization:'Basic xxxx==' --offline

GET /api/values?Authorization:Basic%20xxxx= HTTP/1.1
Host: localhost:5000
Schema: http
User-Agent: dotnet-HTTPie/0.6.2
> dotnet-http :5000/api/values 'Authorization:Basic xxxx==' --offline

GET /api/values?Authorization:Basic%20xxxx= HTTP/1.1
Host: localhost:5000
Schema: http
User-Agent: dotnet-HTTPie/0.6.2

Expected behavior

GET /api/values HTTP/1.1
Host: localhost:5000
Schema: http
Authorization: Basic xxx==
User-Agent: dotnet-HTTPie/0.6.2

Invalid request behavior when there's query string in the request URL

Describe the bug

When there's query string in the request URL, wrong HTTP method fired

To Reproduce

Steps to reproduce the behavior:

http get "https://reservation.weihanli.xyz/health?Page=1&Platform=3&Module=homepageBannerPrimary&Language=en-US&Country=CN&track=newLangTest" -v

Output

POST /health?Page=1&Platform=3&Module=homepageBannerPrimary&Language=en-US&Country=CN&track=newLangTest HTTP/1.1
Host: reservation.weihanli.xyz
Schema: https
Content-Type: application/json;charset=utf-8
User-Agent: dotnet-HTTPie/0.1.1

{"https://reservation.weihanli.xyz/health?Page":"1&Platform=3&Module=homepageBannerPrimary&Language=en-US&Country=CN&track=newLangTest"}

HTTP/1.1 200 OK
Connection: keep-alive
Date: Tue, 10 Aug 2021 08:04:11 GMT
Server: nginx/1.14.1
Transfer-Encoding: chunked

healthy

Expected behavior

Send HTTP GET request without a request body

Additional context

Version: 0.1.1-preview-20210804-003845

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.