diff --git a/option/simple.go b/option/simple.go index 0e5fa478..55bfe930 100644 --- a/option/simple.go +++ b/option/simple.go @@ -31,5 +31,5 @@ type HTTPOutboundOptions struct { Password string `json:"password,omitempty"` TLS *OutboundTLSOptions `json:"tls,omitempty"` Path string `json:"path,omitempty"` - Headers OutboundHeader `json:"headers,omitempty"` + Headers HTTPHeader `json:"headers,omitempty"` } diff --git a/option/types.go b/option/types.go index c97ed0c8..ddabeb6a 100644 --- a/option/types.go +++ b/option/types.go @@ -236,12 +236,14 @@ func DNSQueryTypeToString(queryType uint16) string { return F.ToString(queryType) } -type OutboundHeader map[string]Listable[string] +type HTTPHeader map[string]Listable[string] -func (h OutboundHeader) HTTPHeader() http.Header { +func (h HTTPHeader) Build() http.Header { header := make(http.Header) for name, values := range h { - header[http.CanonicalHeaderKey(name)] = values + for _, value := range values { + header.Add(name, value) + } } return header } diff --git a/option/v2ray_transport.go b/option/v2ray_transport.go index 6c93dcce..54b0de79 100644 --- a/option/v2ray_transport.go +++ b/option/v2ray_transport.go @@ -64,16 +64,16 @@ type V2RayHTTPOptions struct { Host Listable[string] `json:"host,omitempty"` Path string `json:"path,omitempty"` Method string `json:"method,omitempty"` - Headers OutboundHeader `json:"headers,omitempty"` + Headers HTTPHeader `json:"headers,omitempty"` IdleTimeout Duration `json:"idle_timeout,omitempty"` PingTimeout Duration `json:"ping_timeout,omitempty"` } type V2RayWebsocketOptions struct { - Path string `json:"path,omitempty"` - Headers OutboundHeader `json:"headers,omitempty"` - MaxEarlyData uint32 `json:"max_early_data,omitempty"` - EarlyDataHeaderName string `json:"early_data_header_name,omitempty"` + Path string `json:"path,omitempty"` + Headers HTTPHeader `json:"headers,omitempty"` + MaxEarlyData uint32 `json:"max_early_data,omitempty"` + EarlyDataHeaderName string `json:"early_data_header_name,omitempty"` } type V2RayQUICOptions struct{} diff --git a/outbound/http.go b/outbound/http.go index e53d7b65..cfc03216 100644 --- a/outbound/http.go +++ b/outbound/http.go @@ -48,7 +48,7 @@ func NewHTTP(ctx context.Context, router adapter.Router, logger log.ContextLogge Username: options.Username, Password: options.Password, Path: options.Path, - Headers: options.Headers.HTTPHeader(), + Headers: options.Headers.Build(), }), }, nil } diff --git a/transport/v2rayhttp/client.go b/transport/v2rayhttp/client.go index e4859863..d5e8a1f6 100644 --- a/transport/v2rayhttp/client.go +++ b/transport/v2rayhttp/client.go @@ -64,7 +64,7 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt serverAddr: serverAddr, host: options.Host, method: options.Method, - headers: options.Headers.HTTPHeader(), + headers: options.Headers.Build(), transport: transport, http2: tlsConfig != nil, } diff --git a/transport/v2rayhttp/server.go b/transport/v2rayhttp/server.go index 1d5c8650..dcfb07a6 100644 --- a/transport/v2rayhttp/server.go +++ b/transport/v2rayhttp/server.go @@ -55,7 +55,7 @@ func NewServer(ctx context.Context, options option.V2RayHTTPOptions, tlsConfig t host: options.Host, path: options.Path, method: options.Method, - headers: options.Headers.HTTPHeader(), + headers: options.Headers.Build(), } if server.method == "" { server.method = "PUT"