1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-26 09:25:23 +00:00
v2fly/transport/internet/websocket/config.go

38 lines
604 B
Go
Raw Normal View History

2019-02-01 19:08:21 +00:00
// +build !confonly
2016-12-22 23:30:46 +00:00
package websocket
2016-08-13 13:44:36 +00:00
2016-10-02 21:43:58 +00:00
import (
2017-10-13 15:54:04 +00:00
"net/http"
"v2ray.com/core/common"
2016-10-02 21:43:58 +00:00
"v2ray.com/core/transport/internet"
2016-08-13 13:44:36 +00:00
)
2016-10-02 21:43:58 +00:00
2018-08-06 11:48:35 +00:00
const protocolName = "websocket"
2018-03-02 08:26:14 +00:00
func (c *Config) GetNormalizedPath() string {
2017-02-10 10:47:53 +00:00
path := c.Path
if len(path) == 0 {
return "/"
}
if path[0] != '/' {
return "/" + path
}
return path
}
2017-10-13 15:54:04 +00: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 21:43:58 +00:00
func init() {
2019-01-06 19:33:58 +00:00
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
2016-10-02 21:43:58 +00:00
return new(Config)
}))
2016-10-02 21:43:58 +00:00
}