add compression flag option for http request
This commit is contained in:
@@ -107,6 +107,7 @@ func (h *httpHandler) Init(md md.Metadata) error {
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
ResponseHeaderTimeout: h.md.readTimeout,
|
||||
DisableKeepAlives: !h.md.keepalive,
|
||||
DisableCompression: !h.md.compression,
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -627,7 +628,11 @@ func (h *httpHandler) proxyRoundTrip(ctx context.Context, rw io.ReadWriter, req
|
||||
return
|
||||
}
|
||||
|
||||
return resp.Close, nil
|
||||
if resp.ContentLength >= 0 {
|
||||
close = resp.Close
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (h *httpHandler) dial(ctx context.Context, network, addr string) (conn net.Conn, err error) {
|
||||
|
||||
@@ -22,6 +22,7 @@ const (
|
||||
type metadata struct {
|
||||
readTimeout time.Duration
|
||||
keepalive bool
|
||||
compression bool
|
||||
probeResistance *probeResistance
|
||||
enableUDP bool
|
||||
header http.Header
|
||||
@@ -55,10 +56,8 @@ func (h *httpHandler) parseMetadata(md mdata.Metadata) error {
|
||||
h.md.header = hd
|
||||
}
|
||||
|
||||
h.md.keepalive = true
|
||||
if mdutil.IsExists(md, "http.keepalive", "keepalive") {
|
||||
h.md.keepalive = mdutil.GetBool(md, "http.keepalive", "keepalive")
|
||||
}
|
||||
h.md.keepalive = mdutil.GetBool(md, "http.keepalive", "keepalive")
|
||||
h.md.compression = mdutil.GetBool(md, "http.compression", "compression")
|
||||
|
||||
if pr := mdutil.GetString(md, "probeResist", "probe_resist"); pr != "" {
|
||||
if ss := strings.SplitN(pr, ":", 2); len(ss) == 2 {
|
||||
|
||||
Reference in New Issue
Block a user