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