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 {
|
||||
|
||||
@@ -98,6 +98,7 @@ func (h *tunnelHandler) Init(md md.Metadata) (err error) {
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
ResponseHeaderTimeout: h.md.entryPointReadTimeout,
|
||||
DisableKeepAlives: !h.md.entryPointKeepalive,
|
||||
DisableCompression: !h.md.entryPointCompression,
|
||||
}
|
||||
|
||||
for _, ro := range h.options.Recorders {
|
||||
|
||||
@@ -26,6 +26,7 @@ type metadata struct {
|
||||
entryPointID relay.TunnelID
|
||||
entryPointProxyProtocol int
|
||||
entryPointKeepalive bool
|
||||
entryPointCompression bool
|
||||
entryPointReadTimeout time.Duration
|
||||
sniffingWebsocket bool
|
||||
sniffingWebsocketSampleRate float64
|
||||
@@ -45,10 +46,8 @@ func (h *tunnelHandler) parseMetadata(md mdata.Metadata) (err error) {
|
||||
h.md.entryPointID = parseTunnelID(mdutil.GetString(md, "entrypoint.id"))
|
||||
h.md.entryPointProxyProtocol = mdutil.GetInt(md, "entrypoint.ProxyProtocol")
|
||||
|
||||
h.md.entryPointKeepalive = true
|
||||
if mdutil.IsExists(md, "entrypoint.keepalive") {
|
||||
h.md.entryPointKeepalive = mdutil.GetBool(md, "entrypoint.keepalive")
|
||||
}
|
||||
h.md.entryPointKeepalive = mdutil.GetBool(md, "entrypoint.keepalive")
|
||||
h.md.entryPointCompression = mdutil.GetBool(md, "entrypoint.compression")
|
||||
|
||||
h.md.entryPointReadTimeout = mdutil.GetDuration(md, "entrypoint.readTimeout")
|
||||
if h.md.entryPointReadTimeout <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user