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,
|
IdleConnTimeout: 30 * time.Second,
|
||||||
ResponseHeaderTimeout: h.md.readTimeout,
|
ResponseHeaderTimeout: h.md.readTimeout,
|
||||||
DisableKeepAlives: !h.md.keepalive,
|
DisableKeepAlives: !h.md.keepalive,
|
||||||
|
DisableCompression: !h.md.compression,
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -627,7 +628,11 @@ func (h *httpHandler) proxyRoundTrip(ctx context.Context, rw io.ReadWriter, req
|
|||||||
return
|
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) {
|
func (h *httpHandler) dial(ctx context.Context, network, addr string) (conn net.Conn, err error) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const (
|
|||||||
type metadata struct {
|
type metadata struct {
|
||||||
readTimeout time.Duration
|
readTimeout time.Duration
|
||||||
keepalive bool
|
keepalive bool
|
||||||
|
compression bool
|
||||||
probeResistance *probeResistance
|
probeResistance *probeResistance
|
||||||
enableUDP bool
|
enableUDP bool
|
||||||
header http.Header
|
header http.Header
|
||||||
@@ -55,10 +56,8 @@ func (h *httpHandler) parseMetadata(md mdata.Metadata) error {
|
|||||||
h.md.header = hd
|
h.md.header = hd
|
||||||
}
|
}
|
||||||
|
|
||||||
h.md.keepalive = true
|
h.md.keepalive = mdutil.GetBool(md, "http.keepalive", "keepalive")
|
||||||
if mdutil.IsExists(md, "http.keepalive", "keepalive") {
|
h.md.compression = mdutil.GetBool(md, "http.compression", "compression")
|
||||||
h.md.keepalive = mdutil.GetBool(md, "http.keepalive", "keepalive")
|
|
||||||
}
|
|
||||||
|
|
||||||
if pr := mdutil.GetString(md, "probeResist", "probe_resist"); pr != "" {
|
if pr := mdutil.GetString(md, "probeResist", "probe_resist"); pr != "" {
|
||||||
if ss := strings.SplitN(pr, ":", 2); len(ss) == 2 {
|
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,
|
IdleConnTimeout: 30 * time.Second,
|
||||||
ResponseHeaderTimeout: h.md.entryPointReadTimeout,
|
ResponseHeaderTimeout: h.md.entryPointReadTimeout,
|
||||||
DisableKeepAlives: !h.md.entryPointKeepalive,
|
DisableKeepAlives: !h.md.entryPointKeepalive,
|
||||||
|
DisableCompression: !h.md.entryPointCompression,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ro := range h.options.Recorders {
|
for _, ro := range h.options.Recorders {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type metadata struct {
|
|||||||
entryPointID relay.TunnelID
|
entryPointID relay.TunnelID
|
||||||
entryPointProxyProtocol int
|
entryPointProxyProtocol int
|
||||||
entryPointKeepalive bool
|
entryPointKeepalive bool
|
||||||
|
entryPointCompression bool
|
||||||
entryPointReadTimeout time.Duration
|
entryPointReadTimeout time.Duration
|
||||||
sniffingWebsocket bool
|
sniffingWebsocket bool
|
||||||
sniffingWebsocketSampleRate float64
|
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.entryPointID = parseTunnelID(mdutil.GetString(md, "entrypoint.id"))
|
||||||
h.md.entryPointProxyProtocol = mdutil.GetInt(md, "entrypoint.ProxyProtocol")
|
h.md.entryPointProxyProtocol = mdutil.GetInt(md, "entrypoint.ProxyProtocol")
|
||||||
|
|
||||||
h.md.entryPointKeepalive = true
|
h.md.entryPointKeepalive = mdutil.GetBool(md, "entrypoint.keepalive")
|
||||||
if mdutil.IsExists(md, "entrypoint.keepalive") {
|
h.md.entryPointCompression = mdutil.GetBool(md, "entrypoint.compression")
|
||||||
h.md.entryPointKeepalive = mdutil.GetBool(md, "entrypoint.keepalive")
|
|
||||||
}
|
|
||||||
|
|
||||||
h.md.entryPointReadTimeout = mdutil.GetDuration(md, "entrypoint.readTimeout")
|
h.md.entryPointReadTimeout = mdutil.GetDuration(md, "entrypoint.readTimeout")
|
||||||
if h.md.entryPointReadTimeout <= 0 {
|
if h.md.entryPointReadTimeout <= 0 {
|
||||||
|
|||||||
@@ -530,7 +530,11 @@ func (h *Sniffer) httpRoundTrip(ctx context.Context, rw, cc io.ReadWriter, node
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Close, nil
|
if resp.ContentLength >= 0 {
|
||||||
|
close = resp.Close
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func upgradeType(h http.Header) string {
|
func upgradeType(h http.Header) string {
|
||||||
|
|||||||
@@ -393,7 +393,11 @@ func (h *Sniffer) httpRoundTrip(ctx context.Context, rw, cc io.ReadWriter, req *
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Close, nil
|
if resp.ContentLength >= 0 {
|
||||||
|
close = resp.Close
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func upgradeType(h http.Header) string {
|
func upgradeType(h http.Header) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user