This commit is contained in:
crusader 2018-04-14 17:38:15 +09:00
parent 8fbf210d2c
commit 530a422ab7

View File

@ -32,8 +32,9 @@ type Connectors struct {
URL string `json:"url"` URL string `json:"url"`
RequestHeader http.Header `json:"-"` RequestHeader func() http.Header `json:"-"`
Subprotocols []string `json:"subprotocols"`
Subprotocols []string `json:"subprotocols"`
// Jar specifies the cookie jar. // Jar specifies the cookie jar.
// If Jar is nil, cookies are not sent in requests and ignored // If Jar is nil, cookies are not sent in requests and ignored
// in responses. // in responses.
@ -220,7 +221,8 @@ func (c *Connectors) dial() (socket.Conn, *http.Response, error) {
if len(subprotocols) > 0 { if len(subprotocols) > 0 {
req.Header["Sec-WebSocket-Protocol"] = []string{strings.Join(subprotocols, ", ")} req.Header["Sec-WebSocket-Protocol"] = []string{strings.Join(subprotocols, ", ")}
} }
for k, vs := range c.RequestHeader {
for k, vs := range c.RequestHeader() {
switch { switch {
case k == "Host": case k == "Host":
if len(vs) > 0 { if len(vs) > 0 {