Skip to content

Commit

Permalink
Fix COMPRESSION_ERROR in ImpersonateXXX (imroc#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Aug 28, 2023
1 parent 011c0c2 commit 16f0680
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions internal/http2/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,23 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
}

cc.cond = sync.NewCond(&cc.mu)
cc.flow.add(int32(initialWindowSize))

var windowSize int32 = initialWindowSize
var headerTableSize uint32 = initialHeaderTableSize
for _, setting := range t.Settings {
switch setting.ID {
case http2.SettingMaxFrameSize:
cc.maxFrameSize = setting.Val
case http2.SettingMaxHeaderListSize:
t.MaxHeaderListSize = setting.Val
case http2.SettingHeaderTableSize:
headerTableSize = setting.Val
case http2.SettingInitialWindowSize:
windowSize = int32(setting.Val)
}
}

cc.flow.add(windowSize)

// TODO: adjust this writer size to account for frame size +
// MTU + crypto/tls record padding.
Expand All @@ -668,7 +684,7 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
if t.CountError != nil {
cc.fr.countError = t.CountError
}
cc.fr.ReadMetaHeaders = hpack.NewDecoder(initialHeaderTableSize, nil)
cc.fr.ReadMetaHeaders = hpack.NewDecoder(headerTableSize, nil)
cc.fr.MaxHeaderListSize = t.maxHeaderListSize()

// TODO: SetMaxDynamicTableSize, SetMaxDynamicTableSizeLimit on
Expand Down Expand Up @@ -710,7 +726,7 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
cc.nextStreamID = p.StreamID + 2
}

cc.inflow.init(int32(connFlow) + initialWindowSize)
cc.inflow.init(int32(connFlow) + windowSize)
cc.bw.Flush()
if cc.werr != nil {
cc.Close()
Expand Down

0 comments on commit 16f0680

Please sign in to comment.