Replace custom proxy with httputil.ReverseProxy for kubecfg/kubectl.

Fixes #1149 - kubecfg proxy "411 Length Required" error on POST/PUT.
This commit is contained in:
alex
2014-10-21 18:52:18 +01:00
parent d5377e4a39
commit fb2b15a797
8 changed files with 254 additions and 128 deletions

View File

@@ -271,6 +271,38 @@ func TestUnacceptableParamNames(t *testing.T) {
}
}
func TestBody(t *testing.T) {
const data = "test payload"
f, err := ioutil.TempFile("", "test_body")
if err != nil {
t.Fatalf("TempFile error: %v", err)
}
if _, err := f.WriteString(data); err != nil {
t.Fatalf("TempFile.WriteString error: %v", err)
}
f.Close()
c := NewOrDie(&Config{})
tests := []interface{}{[]byte(data), f.Name(), strings.NewReader(data)}
for i, tt := range tests {
r := c.Post().Body(tt)
if r.err != nil {
t.Errorf("%d: r.Body(%#v) error: %v", i, tt, r.err)
continue
}
buf := make([]byte, len(data))
if _, err := r.body.Read(buf); err != nil {
t.Errorf("%d: r.body.Read error: %v", i, err)
continue
}
body := string(buf)
if body != data {
t.Errorf("%d: r.body = %q; want %q", i, body, data)
}
}
}
func TestSetPollPeriod(t *testing.T) {
c := NewOrDie(&Config{})
r := c.Get()