1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-02-20 23:47:21 -05:00

36 lines
611 B
Go
Raw Normal View History

2016-12-23 00:30:46 +01:00
package websocket
2016-08-13 21:44:36 +08:00
2016-10-02 23:43:58 +02:00
import (
2017-10-13 23:54:04 +08:00
"net/http"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/transport/internet"
2016-08-13 21:44:36 +08:00
)
2016-10-02 23:43:58 +02:00
2018-08-06 13:48:35 +02:00
const protocolName = "websocket"
2018-03-02 08:26:14 +00:00
func (c *Config) GetNormalizedPath() string {
2017-02-10 11:47:53 +01:00
path := c.Path
if path == "" {
2017-02-10 11:47:53 +01:00
return "/"
}
if path[0] != '/' {
return "/" + path
}
return path
}
2017-10-13 23:54:04 +08:00
func (c *Config) GetRequestHeader() http.Header {
header := http.Header{}
for _, h := range c.Header {
header.Add(h.Key, h.Value)
}
return header
}
2016-10-02 23:43:58 +02:00
func init() {
2019-01-06 20:33:58 +01:00
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
2016-10-02 23:43:58 +02:00
return new(Config)
}))
2016-10-02 23:43:58 +02:00
}