Skip to content
This repository was archived by the owner on May 29, 2018. It is now read-only.

Commit 1c9672b

Browse files
committed
Support https
1 parent 66dca3e commit 1c9672b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

client.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package httpfstream
22

33
import (
44
"bytes"
5+
"crypto/tls"
56
"errors"
67
"fmt"
78
"github.com/garyburd/go-websocket/websocket"
@@ -107,7 +108,16 @@ func (pw *appendWriteCloser) Close() error {
107108
}
108109

109110
func newClient(u *url.URL, method string) (*websocket.Conn, *http.Response, error) {
110-
c, err := net.Dial("tcp", u.Host)
111+
var c net.Conn
112+
var err error
113+
switch u.Scheme {
114+
case "http":
115+
c, err = net.Dial("tcp", u.Host)
116+
case "https":
117+
c, err = tls.Dial("tcp", u.Host, nil)
118+
default:
119+
return nil, nil, errors.New("unrecognized URL scheme")
120+
}
111121
if err != nil {
112122
return nil, nil, err
113123
}

0 commit comments

Comments
 (0)