mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-13 15:48:39 +00:00
Add header and method support to http2 transport (#755)
Co-authored-by: Shelikhoo <xiaokangwang@outlook.com>
This commit is contained in:
parent
4bb61701b5
commit
e6711d1b48
5 changed files with 106 additions and 33 deletions
|
@ -123,8 +123,22 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
|||
opts := pipe.OptionsFromContext(ctx)
|
||||
preader, pwriter := pipe.New(opts...)
|
||||
breader := &buf.BufferedReader{Reader: preader}
|
||||
|
||||
httpMethod := "PUT"
|
||||
if httpSettings.Method != "" {
|
||||
httpMethod = httpSettings.Method
|
||||
}
|
||||
|
||||
httpHeaders := make(http.Header)
|
||||
|
||||
for _, httpHeader := range httpSettings.Header {
|
||||
for _, httpHeaderValue := range httpHeader.Value {
|
||||
httpHeaders.Set(httpHeader.Name, httpHeaderValue)
|
||||
}
|
||||
}
|
||||
|
||||
request := &http.Request{
|
||||
Method: "PUT",
|
||||
Method: httpMethod,
|
||||
Host: httpSettings.getRandomHost(),
|
||||
Body: breader,
|
||||
URL: &url.URL{
|
||||
|
@ -135,7 +149,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
|||
Proto: "HTTP/2",
|
||||
ProtoMajor: 2,
|
||||
ProtoMinor: 0,
|
||||
Header: make(http.Header),
|
||||
Header: httpHeaders,
|
||||
}
|
||||
// Disable any compression method from server.
|
||||
request.Header.Set("Accept-Encoding", "identity")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue