Merge pull request #145 from iamqizhao/flow
send settingsAck when receiving a settings frame following http2 spec
This commit is contained in:
@ -60,8 +60,8 @@ func (windowUpdate) isItem() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type settings struct {
|
type settings struct {
|
||||||
id http2.SettingID
|
ack bool
|
||||||
val uint32
|
setting []http2.Setting
|
||||||
}
|
}
|
||||||
|
|
||||||
func (settings) isItem() bool {
|
func (settings) isItem() bool {
|
||||||
|
@ -524,6 +524,9 @@ func (t *http2Client) handleRSTStream(f *http2.RSTStreamFrame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Client) handleSettings(f *http2.SettingsFrame) {
|
func (t *http2Client) handleSettings(f *http2.SettingsFrame) {
|
||||||
|
if f.IsAck() {
|
||||||
|
return
|
||||||
|
}
|
||||||
f.ForeachSetting(func(s http2.Setting) error {
|
f.ForeachSetting(func(s http2.Setting) error {
|
||||||
if v, ok := f.Value(s.ID); ok {
|
if v, ok := f.Value(s.ID); ok {
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
@ -541,6 +544,7 @@ func (t *http2Client) handleSettings(f *http2.SettingsFrame) {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
t.controlBuf.put(&settings{ack: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Client) handlePing(f *http2.PingFrame) {
|
func (t *http2Client) handlePing(f *http2.PingFrame) {
|
||||||
@ -680,7 +684,11 @@ func (t *http2Client) controller() {
|
|||||||
case *windowUpdate:
|
case *windowUpdate:
|
||||||
t.framer.writeWindowUpdate(true, i.streamID, i.increment)
|
t.framer.writeWindowUpdate(true, i.streamID, i.increment)
|
||||||
case *settings:
|
case *settings:
|
||||||
t.framer.writeSettings(true, http2.Setting{i.id, i.val})
|
if i.ack {
|
||||||
|
t.framer.writeSettingsAck(true)
|
||||||
|
} else {
|
||||||
|
t.framer.writeSettings(true, i.setting...)
|
||||||
|
}
|
||||||
case *resetStream:
|
case *resetStream:
|
||||||
t.framer.writeRSTStream(true, i.streamID, i.code)
|
t.framer.writeRSTStream(true, i.streamID, i.code)
|
||||||
case *flushIO:
|
case *flushIO:
|
||||||
|
@ -360,6 +360,9 @@ func (t *http2Server) handleRSTStream(f *http2.RSTStreamFrame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Server) handleSettings(f *http2.SettingsFrame) {
|
func (t *http2Server) handleSettings(f *http2.SettingsFrame) {
|
||||||
|
if f.IsAck() {
|
||||||
|
return
|
||||||
|
}
|
||||||
f.ForeachSetting(func(s http2.Setting) error {
|
f.ForeachSetting(func(s http2.Setting) error {
|
||||||
if v, ok := f.Value(http2.SettingInitialWindowSize); ok {
|
if v, ok := f.Value(http2.SettingInitialWindowSize); ok {
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
@ -371,6 +374,7 @@ func (t *http2Server) handleSettings(f *http2.SettingsFrame) {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
t.controlBuf.put(&settings{ack: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Server) handlePing(f *http2.PingFrame) {
|
func (t *http2Server) handlePing(f *http2.PingFrame) {
|
||||||
@ -588,7 +592,11 @@ func (t *http2Server) controller() {
|
|||||||
case *windowUpdate:
|
case *windowUpdate:
|
||||||
t.framer.writeWindowUpdate(true, i.streamID, i.increment)
|
t.framer.writeWindowUpdate(true, i.streamID, i.increment)
|
||||||
case *settings:
|
case *settings:
|
||||||
t.framer.writeSettings(true, http2.Setting{i.id, i.val})
|
if i.ack {
|
||||||
|
t.framer.writeSettingsAck(true)
|
||||||
|
} else {
|
||||||
|
t.framer.writeSettings(true, i.setting...)
|
||||||
|
}
|
||||||
case *resetStream:
|
case *resetStream:
|
||||||
t.framer.writeRSTStream(true, i.streamID, i.code)
|
t.framer.writeRSTStream(true, i.streamID, i.code)
|
||||||
case *flushIO:
|
case *flushIO:
|
||||||
|
Reference in New Issue
Block a user