mirror of https://github.com/Dreamacro/clash.git
Fix: vmess http method may empty
This commit is contained in:
parent
9e78137768
commit
47b6eb1700
|
@ -0,0 +1,8 @@
|
|||
package util
|
||||
|
||||
import "github.com/samber/lo"
|
||||
|
||||
func EmptyOr[T comparable](v T, def T) T {
|
||||
ret, _ := lo.Coalesce(v, def)
|
||||
return ret
|
||||
}
|
|
@ -8,6 +8,8 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"net/textproto"
|
||||
|
||||
"github.com/Dreamacro/clash/common/util"
|
||||
)
|
||||
|
||||
type httpConn struct {
|
||||
|
@ -58,7 +60,7 @@ func (hc *httpConn) Write(b []byte) (int, error) {
|
|||
}
|
||||
|
||||
u := fmt.Sprintf("http://%s%s", host, path)
|
||||
req, _ := http.NewRequest(hc.cfg.Method, u, bytes.NewBuffer(b))
|
||||
req, _ := http.NewRequest(util.EmptyOr(hc.cfg.Method, http.MethodGet), u, bytes.NewBuffer(b))
|
||||
for key, list := range hc.cfg.Headers {
|
||||
req.Header.Set(key, list[rand.Intn(len(list))])
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue