Revert "Allow specifying scheme when proxying"

This commit is contained in:
Filip Grzadkowski
2015-10-07 13:02:35 +02:00
parent 887aeaa101
commit c0532a432a
11 changed files with 70 additions and 235 deletions

View File

@@ -20,12 +20,11 @@ import (
"testing"
)
func TestSplitSchemeNamePort(t *testing.T) {
func TestSplitPort(t *testing.T) {
table := []struct {
in string
name, port, scheme string
valid bool
normalized bool
in string
name, port string
valid bool
}{
{
in: "aoeu:asdf",
@@ -33,50 +32,26 @@ func TestSplitSchemeNamePort(t *testing.T) {
port: "asdf",
valid: true,
}, {
in: "http:aoeu:asdf",
scheme: "http",
name: "aoeu",
port: "asdf",
valid: true,
in: "aoeu:",
name: "aoeu",
valid: true,
}, {
in: "https:aoeu:",
scheme: "https",
name: "aoeu",
port: "",
valid: true,
normalized: false,
in: ":asdf",
name: "",
port: "asdf",
}, {
in: "https:aoeu:asdf",
scheme: "https",
name: "aoeu",
port: "asdf",
valid: true,
}, {
in: "aoeu:",
name: "aoeu",
valid: true,
normalized: false,
}, {
in: ":asdf",
valid: false,
}, {
in: "aoeu:asdf:htns",
valid: false,
in: "aoeu:asdf:htns",
}, {
in: "aoeu",
name: "aoeu",
valid: true,
}, {
in: "",
valid: false,
in: "",
},
}
for _, item := range table {
scheme, name, port, valid := SplitSchemeNamePort(item.in)
if e, a := item.scheme, scheme; e != a {
t.Errorf("%q: Wanted %q, got %q", item.in, e, a)
}
name, port, valid := SplitPort(item.in)
if e, a := item.name, name; e != a {
t.Errorf("%q: Wanted %q, got %q", item.in, e, a)
}
@@ -86,26 +61,5 @@ func TestSplitSchemeNamePort(t *testing.T) {
if e, a := item.valid, valid; e != a {
t.Errorf("%q: Wanted %t, got %t", item.in, e, a)
}
// Make sure valid items round trip through JoinSchemeNamePort
if item.valid {
out := JoinSchemeNamePort(scheme, name, port)
if item.normalized && out != item.in {
t.Errorf("%q: Wanted %s, got %s", item.in, item.in, out)
}
scheme, name, port, valid := SplitSchemeNamePort(out)
if e, a := item.scheme, scheme; e != a {
t.Errorf("%q: Wanted %q, got %q", item.in, e, a)
}
if e, a := item.name, name; e != a {
t.Errorf("%q: Wanted %q, got %q", item.in, e, a)
}
if e, a := item.port, port; e != a {
t.Errorf("%q: Wanted %q, got %q", item.in, e, a)
}
if e, a := item.valid, valid; e != a {
t.Errorf("%q: Wanted %t, got %t", item.in, e, a)
}
}
}
}