Improve HTTP headers option

This commit is contained in:
septs
2023-10-21 12:00:00 +08:00
committed by 世界
parent ac930cf1aa
commit 41fd1778a7
6 changed files with 31 additions and 32 deletions

View File

@@ -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: make(http.Header),
headers: options.Headers.Build(),
transport: transport,
http2: tlsConfig != nil,
}
@@ -83,9 +83,6 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt
if err != nil {
return nil, E.New("failed to set path: " + err.Error())
}
for key, valueList := range options.Headers {
client.headers[key] = valueList
}
client.url = &uri
return client, nil
}

View File

@@ -55,7 +55,7 @@ func NewServer(ctx context.Context, options option.V2RayHTTPOptions, tlsConfig t
host: options.Host,
path: options.Path,
method: options.Method,
headers: make(http.Header),
headers: options.Headers.Build(),
}
if server.method == "" {
server.method = "PUT"
@@ -63,9 +63,6 @@ func NewServer(ctx context.Context, options option.V2RayHTTPOptions, tlsConfig t
if !strings.HasPrefix(server.path, "/") {
server.path = "/" + server.path
}
for key, value := range options.Headers {
server.headers[key] = value
}
server.httpServer = &http.Server{
Handler: server,
ReadHeaderTimeout: C.TCPTimeout,