Skip to content

adrianolmedo/ihttp

Repository files navigation

iHTTP

A simple and lightweight HTTP Client, fully using the Golang standard library net/http package as a CLI tool, inspired in HTTPie and httpie-go.

TO-DO

This proposal is still a work in progress, it is not ready to be used properly for testing REST APIs.

[-] Enable all other separators by default.

[-] Add command-line colors with gookit/color.

Content

Usage

The name of the HTTP Method comes right before the URL argument:

$ http [flags] [METHOD] URL [ITEMS ...]

Execute http -help for more detailed information.

HTTP Method

The METHOD command is optional, by default sends GET request without using it:

$ http httpbingo.org/get

Both ways will send a GET request:

$ http GET httpbingo.org/get

Make GET requests containing a body with foo=bar notation:

$ http GET httpbingo.org/get hello=world

Send a POST request automatically specifying a body:

$ http httpbingo.org/post hello=world

So use POST for requests with body:

$ http POST httpbingo.org/post hello=world

Query string params

It admit the param==value notation for add parameters to the URL

$ http https://api.github.com/search/repositories q==go per_page==1

Any special characters are automatically escaped from the URL.

Unlike the original parameters in the URL, which will not be altered either by iHTTP.

HTTP Headers

Set custom headers with the Header:Value notation:

$ http -v httpbingo.org/headers User-Agent:Bacon/1.0 'Cookie:valued-visitor=yes;foo=bar' \
    X-Foo:Bar Referer:https://httpbingo.org/

Pass -v flag for see the HTTP Request in the output:

GET /headers HTTP/1.1
Accept-Encoding: gzip
Cookie: valued-visitor=yes;foo=bar
Host: httpbingo.org
Referer: https://httpbingo.org/
User-Agent: Bacon/1.0
X-Foo: Bar

NOTE: iHTTP has no HTTP Headers by default, only those determined by the Go net/http stdlib.

Shortcut for localhost

Supports curl-like shorthand for localhost:

$ http :

The URL is processed as http://localhost.

If the port is omitted, the port 80 is assumed.

$ http -v :
GET / HTTP/1.1
Host: localhost

Another example:

$ http :3000/bar

The URL is processed as http://localhost:3000:

$ http -v :3000/bar
GET /bar HTTP/1.1
Host: localhost:3000

Scheme

You can install the iHTTP executable as https:

$ https example.org 

Which the default scheme will be https://, it will make a request to https://example.org.

Also you can change the scheme value with -scheme:

$ http -scheme https example.org

Again this will make a request to https://example.org.

Roadmap

  • API for add new HTTP Methods and separators.
  • Plugin system for extend functionalities.

About

Simple and lightweight HTTP Client as CLI tool

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published