From 5cd09f5e9b12b3b705010540586b096f1e92def5 Mon Sep 17 00:00:00 2001 From: Rafal Jeczalik Date: Tue, 23 Feb 2016 00:02:03 +0100 Subject: [PATCH] api: handle net/http as cli request --- api/api.go | 2 +- api/api_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/api.go b/api/api.go index 8d9101c..32670a1 100644 --- a/api/api.go +++ b/api/api.go @@ -26,7 +26,7 @@ const ( APPLICATION_JSON = "application/json" ) -var cliUserAgentExp = regexp.MustCompile("^(?i)(curl|wget|fetch\\slibfetch)\\/.*$") +var cliUserAgentExp = regexp.MustCompile(`^(?i)((curl|wget|fetch\slibfetch|Go-http-client)\/.*|Go\s1\.1\spackage\shttp)$`) type API struct { CORS bool diff --git a/api/api_test.go b/api/api_test.go index 89ecf0d..045f183 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -70,6 +70,9 @@ func TestGetIP(t *testing.T) { {s.URL, false, "127.0.0.1\n", "curl/7.26.0", 200}, {s.URL, false, "127.0.0.1\n", "Wget/1.13.4 (linux-gnu)", 200}, {s.URL, false, "127.0.0.1\n", "fetch libfetch/2.0", 200}, + {s.URL, false, "127.0.0.1\n", "Go 1.1 package http", 200}, + {s.URL, false, "127.0.0.1\n", "Go-http-client/1.1", 200}, + {s.URL, false, "127.0.0.1\n", "Go-http-client/2.0", 200}, {s.URL + "/x-ifconfig-ip.json", false, toJSON("x-ifconfig-ip", "127.0.0.1"), "", 200}, {s.URL, true, toJSON("x-ifconfig-ip", "127.0.0.1"), "", 200}, {s.URL + "/foo", false, "no value found for: foo", "curl/7.26.0", 404},