mirror of https://github.com/golang/go.git
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: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
64e2a71701
commit
2747ca351e
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue