Merge pull request #10 from rjeczalik/master

api: handle net/http as cli request
This commit is contained in:
Martin Polden 2016-02-23 13:50:23 +01:00
commit 72100d8e48
2 changed files with 4 additions and 1 deletions

View File

@ -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

View File

@ -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},