Ack Ping frame

This commit is contained in:
iamqizhao
2015-04-24 13:55:46 -07:00
parent c5984b9a7d
commit 03b78f7e01
3 changed files with 18 additions and 2 deletions

View File

@ -85,6 +85,14 @@ func (flushIO) isItem() bool {
return true 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() // quotaPool is a pool which accumulates the quota and sends it to acquire()
// when it is available. // when it is available.
type quotaPool struct { type quotaPool struct {

View File

@ -573,7 +573,7 @@ func (t *http2Client) handleSettings(f *http2.SettingsFrame) {
} }
func (t *http2Client) handlePing(f *http2.PingFrame) { 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) { func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) {
@ -719,6 +719,10 @@ func (t *http2Client) controller() {
t.framer.writeRSTStream(true, i.streamID, i.code) t.framer.writeRSTStream(true, i.streamID, i.code)
case *flushIO: case *flushIO:
t.framer.flushWrite() 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: default:
log.Printf("transport: http2Client.controller got unexpected item type %v\n", i) log.Printf("transport: http2Client.controller got unexpected item type %v\n", i)
} }

View File

@ -385,7 +385,7 @@ func (t *http2Server) handleSettings(f *http2.SettingsFrame) {
} }
func (t *http2Server) handlePing(f *http2.PingFrame) { 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) { func (t *http2Server) handleWindowUpdate(f *http2.WindowUpdateFrame) {
@ -609,6 +609,10 @@ func (t *http2Server) controller() {
t.framer.writeRSTStream(true, i.streamID, i.code) t.framer.writeRSTStream(true, i.streamID, i.code)
case *flushIO: case *flushIO:
t.framer.flushWrite() 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: default:
log.Printf("transport: http2Server.controller got unexpected item type %v\n", i) log.Printf("transport: http2Server.controller got unexpected item type %v\n", i)
} }