Commit 2747ca35 authored by Harshavardhana's avatar Harshavardhana Committed by Brad Fitzpatrick

net/http: don't remove Expect Request header in Server.

Fixes #13893

Change-Id: I2577b38fdb19299227dc146f707cf9df663dcdfc
Reviewed-on: https://go-review.googlesource.com/18471
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 64e2a717
......@@ -3639,6 +3639,33 @@ func TestTolerateCRLFBeforeRequestLine(t *testing.T) {
}
}
func TestIssue13893_Expect100(t *testing.T) {
// test that the Server doesn't filter out Expect headers.
req := reqBytes(`PUT /readbody HTTP/1.1
User-Agent: PycURL/7.22.0
Host: 127.0.0.1:9000
Accept: */*
Expect: 100-continue
Content-Length: 10
HelloWorld
`)
var buf bytes.Buffer
conn := &rwTestConn{
Reader: bytes.NewReader(req),
Writer: &buf,
closec: make(chan bool, 1),
}
ln := &oneConnListener{conn: conn}
go Serve(ln, HandlerFunc(func(w ResponseWriter, r *Request) {
if _, ok := r.Header["Expect"]; !ok {
t.Error("Expect header should not be filtered out")
}
}))
<-conn.closec
}
func TestIssue11549_Expect100(t *testing.T) {
req := reqBytes(`PUT /readbody HTTP/1.1
User-Agent: PycURL/7.22.0
......
......@@ -1452,7 +1452,6 @@ func (c *conn) serve() {
// Wrap the Body reader with one that replies on the connection
req.Body = &expectContinueReader{readCloser: req.Body, resp: w}
}
req.Header.Del("Expect")
} else if req.Header.get("Expect") != "" {
w.sendExpectationFailed()
return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment