Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/stream/http/connpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ func (ac *activeClient) OnResetStream(reason types.StreamResetReason) {
ac.client.ConnID())
}
ac.closeConn = true
} else if reason == types.StreamRemoteReset && !ac.closed {
if log.DefaultLogger.GetLogLevel() >= log.DEBUG {
log.DefaultLogger.Debugf("[stream] [http] stream remote reset, blow client away also, Connection = %d",
ac.client.ConnID())
}
ac.closeConn = true
}
}

Expand Down
20 changes: 16 additions & 4 deletions pkg/stream/http/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,17 @@ func newClientStreamConnection(ctx context.Context, connection types.ClientConne
if pgc, err := variable.Get(ctx, types.VariableProxyGeneralConfig); err == nil && pgc != nil {
if extendConfig, ok := pgc.(map[api.ProtocolName]interface{}); ok {
if http1Config, ok := extendConfig[protocol.HTTP1]; ok {
if config, ok := http1Config.(map[string]interface{}); ok {
switch config := http1Config.(type) {
case map[string]interface{}:
if v, ok := config["max_header_size"]; ok {
// json.Unmarshal stores float64 for JSON numbers in the interface{}
// see doc: https://golang.org/pkg/encoding/json/#Unmarshal
if fv, ok := v.(float64); ok {
maxResponseHeaderSize = int(fv)
}
}
case StreamConfig:
maxResponseHeaderSize = config.MaxHeaderSize
}
}
}
Expand Down Expand Up @@ -295,7 +298,14 @@ func (conn *clientStreamConnection) serve() {
log.Proxy.Errorf(s.connection.context, "[stream] [http] client stream connection wait response error: %s", err)
reason := conn.resetReason
if reason == "" {
reason = types.StreamRemoteReset
var errSmallBuffer *fasthttp.ErrSmallBuffer
switch {
case errors.As(err, &errSmallBuffer):
// response header size over max_header_size limit, set reason types.StreamLocalReset
reason = types.StreamLocalReset
default:
reason = types.StreamRemoteReset
}
}
s.ResetStream(reason)
}
Expand Down Expand Up @@ -712,7 +722,8 @@ func (s *clientStream) endStream() {
err := s.doSend()

if err != nil {
log.Proxy.Errorf(s.stream.ctx, "[stream] [http] send client request error: %+v", err)
log.Proxy.Errorf(s.stream.ctx, "[stream] [http] send client request, connID %d, error: %+v",
s.connection.conn.ID(), err)

if err == types.ErrConnectionHasClosed {
s.ResetStream(types.StreamConnectionFailed)
Expand All @@ -723,7 +734,8 @@ func (s *clientStream) endStream() {
}

if log.Proxy.GetLogLevel() >= log.DEBUG {
log.Proxy.Debugf(s.stream.ctx, "[stream] [http] send client request, requestId = %v", s.stream.id)
log.Proxy.Debugf(s.stream.ctx, "[stream] [http] send client request, requestId = %v, connID %d",
s.stream.id, s.connection.conn.ID())
}
s.connection.requestSent <- true
}
Expand Down