From 5ad48ad3fa929485973e86b2ad949c58446fc70e Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Fri, 15 Apr 2016 20:19:14 +0200 Subject: [PATCH] Add support for HTTPie. Fixes #13 --- api/api.go | 2 +- api/api_test.go | 1 + index.html | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/api.go b/api/api.go index 1de96f8..9efee2b 100644 --- a/api/api.go +++ b/api/api.go @@ -18,7 +18,7 @@ import ( const APPLICATION_JSON = "application/json" -var cliUserAgentExp = regexp.MustCompile(`^(?i)((curl|wget|fetch\slibfetch|Go-http-client)\/.*|Go\s1\.1\spackage\shttp)$`) +var cliUserAgentExp = regexp.MustCompile(`^((curl|Wget|fetch\slibfetch|Go-http-client|HTTPie)\/.*|Go\s1\.1\spackage\shttp)$`) type API struct { CORS bool diff --git a/api/api_test.go b/api/api_test.go index b3ba6ba..8654a75 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -132,6 +132,7 @@ func TestCLIMatcher(t *testing.T) { {"curl/7.26.0", true}, {"Wget/1.13.4 (linux-gnu)", true}, {"fetch libfetch/2.0", true}, + {"HTTPie/0.9.3", true}, {browserUserAgent, false}, } for _, tt := range tests { diff --git a/index.html b/index.html index 163b89d..2c2ef1d 100644 --- a/index.html +++ b/index.html @@ -37,7 +37,7 @@

What is my IP address?

{{ .IP }}

Multiple command line HTTP clients are supported, - including curl, GNU + including curl, httpie, GNU Wget and fetch.

@@ -49,6 +49,9 @@ $ curl ifconfig.co {{ .IP }} +$ http ifconfig.co +{{ .IP }} + $ wget -qO- ifconfig.co {{ .IP }}