From: Brad Fitzpatrick Date: Sat, 7 Nov 2015 15:51:20 +0000 (+0100) Subject: net/http: update http2 bundle X-Git-Tag: go1.6beta1~597 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=525d4bd5203ce0bc6d36add058041dcdfb979161;p=gostls13.git net/http: update http2 bundle To rev a179abb (handle Transport PING frames). Change-Id: I6e1eef2c9586c23f231803d9364d921248722f12 Reviewed-on: https://go-review.googlesource.com/16732 Reviewed-by: Blake Mizerany Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go index c129c98aa9..92ad5d2d92 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go @@ -832,6 +832,8 @@ type http2PingFrame struct { Data [8]byte } +func (f *http2PingFrame) IsAck() bool { return f.Flags.Has(http2FlagPingAck) } + func http2parsePingFrame(fh http2FrameHeader, payload []byte) (http2Frame, error) { if len(payload) != 8 { return nil, http2ConnectionError(http2ErrCodeFrameSize) @@ -2824,7 +2826,7 @@ func (sc *http2serverConn) processFrame(f http2Frame) error { func (sc *http2serverConn) processPing(f *http2PingFrame) error { sc.serveG.check() - if f.Flags.Has(http2FlagSettingsAck) { + if f.IsAck() { return nil } @@ -4279,6 +4281,8 @@ func (rl *http2clientConnReadLoop) run() error { err = rl.processPushPromise(f) case *http2WindowUpdateFrame: err = rl.processWindowUpdate(f) + case *http2PingFrame: + err = rl.processPing(f) default: cc.logf("Transport: unhandled response frame type %T", f) } @@ -4496,6 +4500,20 @@ func (rl *http2clientConnReadLoop) processResetStream(f *http2RSTStreamFrame) er return nil } +func (rl *http2clientConnReadLoop) processPing(f *http2PingFrame) error { + if f.IsAck() { + + return nil + } + cc := rl.cc + cc.wmu.Lock() + defer cc.wmu.Unlock() + if err := cc.fr.WritePing(true, f.Data); err != nil { + return err + } + return cc.bw.Flush() +} + func (rl *http2clientConnReadLoop) processPushPromise(f *http2PushPromiseFrame) error { return http2ConnectionError(http2ErrCodeProtocol)