httpie-like HTTP client written in Go

Related tags

Network go http client
Overview

httpie-go

CircleCI

httpie-go screenshot

httpie-go (ht) is a user-friendly HTTP client CLI. Requests can be issued with fewer types compared to curl. Responses are displayed with syntax highlighting.

httpie-go is a clone of httpie. Since httpie-go is written in Go, it is a single binary and does not require a heavy runtime.

Examples

This example sends a GET request to http://httpbin.org/get.

$ ht GET httpbin.org/get

The second example sends a POST request with JSON body {"hello": "world", "foo": "bar"}.

$ ht POST httpbin.org/post hello=world foo=bar

You can see the request that is being sent with -v option.

$ ht -v POST httpbin.org/post hello=world foo=bar

Request HTTP headers can be specified in the form of key:value.

$ ht -v POST httpbin.org/post X-Foo:foobar

Disable TLS verification.

$ ht --verify=no https://httpbin.org/get

Download a file.

$ ht --download <any url you want>

Documents

Although httpie-go does not currently have documents, you can refer to the original httpie's documentation since httpie-go is a clone of httpie. Note that some minor options are yet to be implemented in httpie-go.

How to build

make

For non-standard Linux system like Android termux, use following method to avoid the DNS issue.

make build-termux
Issues
  • fix dns issue under termux and make it static;

    fix dns issue under termux and make it static;

    For system like Termux without standard /etc/resolve.conf golang program can run into DNS issue. The fix set default DNS other than [::1] to fix the issue. Feel free to adapt the fix like making it a separate Make rule.

    opened by chaoqing 3
  • feat: colorize rfc7807 error repsonses

    feat: colorize rfc7807 error repsonses

    This adds color pretty-printing support for RFC 7807 error responses that use application/problem+json as the content type.

    See also RFC 6839 §3.1 which defines the general +json suffix.

    Thanks for making this awesome tool!

    opened by danielgtaylor 3
  • use json.Tokens instead of reflect

    use json.Tokens instead of reflect

    hey nojima, thanks for creating this! i went looking up online for a go alternative to httpie because the difference in responsiveness between curl and httpie had suddenly struck on me :)

    I've made this mostly to scratch my own itch which I already had on httpie, which was the fact it was doing alphabetical sorting on the returned result, which I don't really want since generally in APIs objects are structured in an order that makes sense.

    this has the side effect of changing from using interface{} to store the value, thus do an initial costly unmarshalling into a generic interface{} and then try to find our way through it using reflect, to using json.Token, which is a much lighter alternative (and lets us only touch type switches and assertions instead of the reflect package - phew!).

    numbers are also represented more accurately retaining their form in the original json, thanks to json.Number.

    if compatibility is the goal, i would understand this not being merged - but as I said, I mostly did this so that the arbitrary sorting didn't bother me anymore :)

    cheers :clinking_glasses:

    opened by thehowl 3
  • MainWithOptions to allow overriding transport.

    MainWithOptions to allow overriding transport.

    Hello! First, I wanted to say thank you for your lovely clone of HTTPie.

    Second, I'd like to contribute this small patch which I had to make in order to implement my own little thing: https://github.com/deref/pier

    This PR introduces a function MainWithOptions that takes one new option: Transport, which allows you to override the http.RoundTripper instance used as part of the http.Client. Making this dependency injectable allowed me to use httpie-go as a library against an in-memory http.Handler using httptest.ResponseRecorder. For details, see https://github.com/deref/pier/blob/ae2d5cdd8f2f36ef7d186b19a9661a56ba926cae/main.go

    If for some reason this patch is not acceptable as is, but some form of this change would be, let me know and I'm happy to make adjustments. Otherwise, I'm happy to maintain a fork as long as needed.

    Thanks!

    • Brandon
    opened by brandonbloom 2
  • Fixup dropped line from PR #70

    Fixup dropped line from PR #70

    Hi @nojima, I'm just now getting around to removing the replace directive from my go.mod file and I realized that in the shuffle of the code review feedback on #70, I somehow dropped this critical line of code! Without this, the feature doesn't work at all :) Please merge. Apologies for the noise. Thank you!

    opened by brandonbloom 1
  • Add option --check-status

    Add option --check-status

    HTTPie has the option --check-status, which can be used to make HTTPie exit with an return code != 0 if the HTTP request code is in the range [300..600[, which simplifies using HTTPie in shell scripts. httpie-go was lacking this option.

    Disclaimer: I'm a golang newby.

    opened by pmhahn 1
  • Simplify getExitStatus

    Simplify getExitStatus

    • There is no need to look at the follow option. When the follow option is enabled, the status code of the response will never be 3xx.
    • Instead of using if-else, calculate the status code by division.
    • go fmt
    opened by nojima 0
  • [Question] any chance we can get a arm64 build for linux and macos?

    [Question] any chance we can get a arm64 build for linux and macos?

    The prebuilt binaries provided on release page only support amd64 architecture, how about building this tool for arm64 platforms as well on Linux and MacOS? Is it possible with CircleCI?

    opened by athrunsun 0
  • Using --follow with --verbose, the redirects in the middle aren't displayed

    Using --follow with --verbose, the redirects in the middle aren't displayed

    httpie-go skips everything in the middle and shows the final result. HTTPie shows all the redirects and their related headers or bodies (respective of params).

    HTTPie-go

    ➜  auth git:(gds) ht -Fvh https://google.com
    HTTP/2.0 200 OK
    Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
    Cache-Control: private, max-age=0
    Content-Type: text/html; charset=ISO-8859-1
    Date: Mon, 26 Jul 2021 21:45:40 GMT
    Expires: -1
    P3p: CP="This is not a P3P policy! See g.co/p3phelp for more info."
    Server: gws
    Set-Cookie: 1P_JAR=2021-07-26-21; expires=Wed, 25-Aug-2021 21:45:40 GMT; path=/; domain=.google.com; Secure
    Set-Cookie: NID=220=PbsBwy_-qlQkTuwp-JCnTZDn1L1ejUzmdU6ntxNfPikOOSY01__hvR1WPG7wTpSCMG55jkcj1ScIz_6cNG7flk3Avfb6KKb2BH9Nv5f-vXanfdB23NdLn6LUcZPUkNrTh26S3L7sYSpb6OUMpDeYruSUM_GwVUDFbB-TrLir3JM; expires=Tue, 25-Jan-2022 21:45:40 GMT; path=/; domain=.google.com; HttpOnly
    X-Frame-Options: SAMEORIGIN
    X-Xss-Protection: 0
    

    HTTPie (python)

    ➜  auth git:(gds) http -Fvh https://google.com
    HTTP/1.1 301 Moved Permanently
    Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
    Cache-Control: public, max-age=2592000
    Content-Length: 220
    Content-Type: text/html; charset=UTF-8
    Date: Mon, 26 Jul 2021 21:45:52 GMT
    Expires: Wed, 25 Aug 2021 21:45:52 GMT
    Location: https://www.google.com/
    Server: gws
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 0
    
    HTTP/1.1 200 OK
    Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
    Cache-Control: private, max-age=0
    Content-Encoding: gzip
    Content-Type: text/html; charset=ISO-8859-1
    Date: Mon, 26 Jul 2021 21:45:53 GMT
    Expires: -1
    P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
    Server: gws
    Set-Cookie: 1P_JAR=2021-07-26-21; expires=Wed, 25-Aug-2021 21:45:53 GMT; path=/; domain=.google.com; Secure
    Set-Cookie: NID=220=ATD0Gaaal5313XDyFgcFsa8ENCW3IVbeN3oaO-SHsLvq5LZMZrmhgxtEkIu08j7ou_kt8HzxThBUA28uPJrAmopGHIIzqsAqgIE0oTHj1r4Wb0sGjqTDDBCf3-riucl0uCMC8LWgZkbPPP1P6apTqj374EFfJCkj1jlBbjVyuvE; expires=Tue, 25-Jan-2022 21:45:53 GMT; path=/; domain=.google.com; HttpOnly
    Transfer-Encoding: chunked
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 0
    
    opened by fearphage 0
  • Support `~/.netrc` for authenticating requests

    Support `~/.netrc` for authenticating requests

    The original Python implementation of httpie supports reading from ~/.netrc by default. curl supports ~/.netrc with the -n flag. It'd be great if httpie-go could also support ~/.netrc

    opened by abatilo 0
Releases(v0.7.0)
Owner
Yusuke Nojima
Yusuke Nojima
Tailscale-client-go - A client implementation for the Tailscale HTTP API

tailscale-client-go A client implementation for the Tailscale HTTP API Example p

David Bond 10 Jun 29, 2022
A http-relay server/client written in golang to forward requests to a service behind a nat router from web

http-relay This repo is WIP http-relay is a server/client application written in go(lang) to forward http(s) requests to an application behind a nat r

john dev 1 Dec 16, 2021
Fork of Go stdlib's net/http that works with alternative TLS libraries like refraction-networking/utls.

github.com/ooni/oohttp This repository contains a fork of Go's standard library net/http package including patches to allow using this HTTP code with

Open Observatory of Network Interference (OONI) 26 Jul 22, 2022
Golang http&grpc server for gracefully shutdown like nginx -s reload

supervisor Golang http & grpc server for gracefully shutdown like nginx -s reload if you want a server which would be restarted without stopping servi

Terry Fei 0 Jan 8, 2022
Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http

fasthttp Fast HTTP implementation for Go. Currently fasthttp is successfully used by VertaMedia in a production serving up to 200K rps from more than

Aliaksandr Valialkin 18.2k Aug 15, 2022
Go HTTP tunnel is a reverse tunnel based on HTTP/2.

Go HTTP tunnel is a reverse tunnel based on HTTP/2. It enables you to share your localhost when you don't have a public IP.

Michal Jan Matczuk 2.9k Aug 12, 2022
Go-http-sleep: Delayed response http server, useful for testing various timeout issue for application running behind proxy

delayed response http server, useful for testing various timeout issue for application running behind proxy

guessi 0 Jan 22, 2022
Http-logging-proxy - A HTTP Logging Proxy For Golang

http-logging-proxy HTTP Logging Proxy Description This project builds a simple r

null 3 Aug 1, 2022
Http-recorder - Application for record http response as static files

http-recorder This is a application for record http response as static files. Th

null 1 Mar 21, 2022
Http-server - A HTTP server and can be accessed via TLS and non-TLS mode

Application server.go runs a HTTP/HTTPS server on the port 9090. It gives you 4

Vedant Pareek 0 Feb 3, 2022
An easy HTTP client for Go. Inspired by the immortal Requests.

rek An easy HTTP client for Go inspired by Requests, plus all the Go-specific goodies you'd hope for in a client. Here's an example: // GET request re

Luc Perkins 384 Jul 22, 2022
golang useful http client

gequest 简体中文 | English 一个轻量级的、语义化的、链式操作的 golang http 客户端封装 用法 要求: golang >= 1.14 安装 go get -u "github.com/smallcatx0/gequest" import ( request "g

null 3 Sep 18, 2021
simplified helper to create http client calls to test your server

Overview Simplified creating http client calls for testing http servers or handlers. Cleanly build and execute http requests in tests so that you can

Adam Straughan 2 Nov 1, 2021
go HTTP client that makes it plain simple to configure TLS, basic auth, retries on specific errors, keep-alive connections, logging, timeouts etc.

goat Goat, is an HTTP client built on top of a standard Go http package, that is extremely easy to configure; no googling required. The idea is simila

VSPAZ 1 Jun 25, 2022
viagh.NewHTTPClient returns a *http.Client that makes API requests via the gh command.

viagh viagh.NewHTTPClient returns a *http.Client that makes API requests via the gh command. Why viagh? When writing a GitHub CLI extension, the exten

Ken’ichiro Oyama 1 Dec 24, 2021
Prisma Client Go is an auto-generated and fully type-safe database client

Prisma Client Go Typesafe database access for Go Quickstart • Website • Docs • API reference • Blog • Slack • Twitter Prisma Client Go is an auto-gene

Prisma 1.3k Aug 12, 2022
The Dual-Stack Dynamic DNS client, the world's first dynamic DNS client built for IPv6.

dsddns DsDDNS is the Dual-Stack Dynamic DNS client. A dynamic DNS client keeps your DNS records in sync with the IP addresses associated with your hom

Ryan Young 12 Aug 10, 2022
Go Substrate RPC Client (GSRPC)Go Substrate RPC Client (GSRPC)

Go Substrate RPC Client (GSRPC) Substrate RPC client in Go. It provides APIs and types around Polkadot and any Substrate-based chain RPC calls. This c

Chino Chang 1 Nov 11, 2021