Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #81 from aandryashin/master
Browse files Browse the repository at this point in the history
Old browsers protocol support
  • Loading branch information
vania-pooh authored Jun 16, 2017
2 parents c0d8f36 + 7754873 commit d5c2cdc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net"
"net/http"
"net/http/httputil"
"net/url"
"strings"
"sync"
"time"
Expand All @@ -36,6 +37,11 @@ const (
)

var (
httpClient *http.Client = &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
quota = make(map[string]Browsers)
routes Routes = make(Routes)
num uint64
Expand Down Expand Up @@ -92,13 +98,22 @@ func (h *Host) session(ctx context.Context, header http.Header, c caps) (map[str
defer cancel()
req = req.WithContext(ctx)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
resp, err := httpClient.Do(req)
if resp != nil {
defer resp.Body.Close()
}
if err != nil {
return nil, seleniumError
}
location := resp.Header.Get("Location")
if location != "" {
l, err := url.Parse(location)
if err != nil {
return nil, seleniumError
}
fragments := strings.Split(l.Path, "/")
return map[string]interface{}{"sessionId": fragments[len(fragments)-1]}, browserStarted
}
var reply map[string]interface{}
err = json.NewDecoder(resp.Body).Decode(&reply)
if err != nil {
Expand Down

0 comments on commit d5c2cdc

Please sign in to comment.