From 03b78f7e012dac114c638dbdb0abe52d6c6db30d Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Fri, 24 Apr 2015 13:55:46 -0700 Subject: [PATCH] Ack Ping frame --- transport/control.go | 8 ++++++++ transport/http2_client.go | 6 +++++- transport/http2_server.go | 6 +++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/transport/control.go b/transport/control.go index 9d134a36..306b5851 100644 --- a/transport/control.go +++ b/transport/control.go @@ -85,6 +85,14 @@ func (flushIO) isItem() bool { return true } +type ping struct { + ack bool +} + +func (ping) isItem() bool { + return true +} + // quotaPool is a pool which accumulates the quota and sends it to acquire() // when it is available. type quotaPool struct { diff --git a/transport/http2_client.go b/transport/http2_client.go index 8fde59d2..98cfb803 100644 --- a/transport/http2_client.go +++ b/transport/http2_client.go @@ -573,7 +573,7 @@ func (t *http2Client) handleSettings(f *http2.SettingsFrame) { } func (t *http2Client) handlePing(f *http2.PingFrame) { - // TODO(zhaoq): PingFrame handler to be implemented" + t.controlBuf.put(&ping{true}) } func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) { @@ -719,6 +719,10 @@ func (t *http2Client) controller() { t.framer.writeRSTStream(true, i.streamID, i.code) case *flushIO: t.framer.flushWrite() + case *ping: + // TODO(zhaoq): Ack with all-0 data now. will change to some + // meaningful content when this is actually in use. + t.framer.writePing(true, i.ack, [8]byte{}) default: log.Printf("transport: http2Client.controller got unexpected item type %v\n", i) } diff --git a/transport/http2_server.go b/transport/http2_server.go index 0399c3b0..3dfc49e0 100644 --- a/transport/http2_server.go +++ b/transport/http2_server.go @@ -385,7 +385,7 @@ func (t *http2Server) handleSettings(f *http2.SettingsFrame) { } func (t *http2Server) handlePing(f *http2.PingFrame) { - // TODO(zhaoq): PingFrame handler to be implemented + t.controlBuf.put(&ping{true}) } func (t *http2Server) handleWindowUpdate(f *http2.WindowUpdateFrame) { @@ -609,6 +609,10 @@ func (t *http2Server) controller() { t.framer.writeRSTStream(true, i.streamID, i.code) case *flushIO: t.framer.flushWrite() + case *ping: + // TODO(zhaoq): Ack with all-0 data now. will change to some + // meaningful content when this is actually in use. + t.framer.writePing(true, i.ack, [8]byte{}) default: log.Printf("transport: http2Server.controller got unexpected item type %v\n", i) }