github.com/v2fly/v2ray-core/v4@v4.45.2/transport/internet/websocket/config.go (about)

     1  //go:build !confonly
     2  // +build !confonly
     3  
     4  package websocket
     5  
     6  import (
     7  	"net/http"
     8  
     9  	"github.com/v2fly/v2ray-core/v4/common"
    10  	"github.com/v2fly/v2ray-core/v4/transport/internet"
    11  )
    12  
    13  const protocolName = "websocket"
    14  
    15  func (c *Config) GetNormalizedPath() string {
    16  	path := c.Path
    17  	if path == "" {
    18  		return "/"
    19  	}
    20  	if path[0] != '/' {
    21  		return "/" + path
    22  	}
    23  	return path
    24  }
    25  
    26  func (c *Config) GetRequestHeader() http.Header {
    27  	header := http.Header{}
    28  	for _, h := range c.Header {
    29  		header.Add(h.Key, h.Value)
    30  	}
    31  	return header
    32  }
    33  
    34  func init() {
    35  	common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
    36  		return new(Config)
    37  	}))
    38  }