Skip to content

Commit f1d0b43

Browse files
committed
Remove http package
1 parent 35b7abd commit f1d0b43

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

http/headers/headers.go

Lines changed: 0 additions & 7 deletions
This file was deleted.

http/mediatypes/mediatypes.go

Lines changed: 0 additions & 7 deletions
This file was deleted.

remote.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import (
1919

2020
"github.com/blang/semver"
2121
"github.com/tebeka/selenium/firefox"
22-
"github.com/tebeka/selenium/http/headers"
23-
"github.com/tebeka/selenium/http/mediatypes"
2422
"github.com/tebeka/selenium/log"
2523
)
2624

@@ -61,15 +59,18 @@ type remoteWD struct {
6159
// server.
6260
var HTTPClient = http.DefaultClient
6361

62+
// jsonContentType is JSON content type.
63+
const jsonContentType = "application/json"
64+
6465
func newRequest(method string, url string, data []byte) (*http.Request, error) {
6566
request, err := http.NewRequest(method, url, bytes.NewBuffer(data))
6667
if err != nil {
6768
return nil, err
6869
}
6970
if data != nil {
70-
request.Header.Add(headers.ContentType, mediatypes.ApplicationJSONUtf8)
71+
request.Header.Add("Content-Type", jsonContentType)
7172
}
72-
request.Header.Add(headers.Accept, mediatypes.ApplicationJSON)
73+
request.Header.Add("Accept", jsonContentType)
7374

7475
return request, nil
7576
}
@@ -150,19 +151,19 @@ func executeCommand(method, url string, data []byte) (json.RawMessage, error) {
150151
buf = prettyBuf.Bytes()
151152
}
152153
}
153-
debugLog("<- %s [%s]\n%s", response.Status, response.Header[headers.ContentType], buf)
154+
debugLog("<- %s [%s]\n%s", response.Status, response.Header["Content-Type"], buf)
154155
}
155156
if err != nil {
156157
return nil, errors.New(response.Status)
157158
}
158159

159-
fullCType := response.Header.Get(headers.ContentType)
160+
fullCType := response.Header.Get("Content-Type")
160161
cType, _, err := mime.ParseMediaType(fullCType)
161162
if err != nil {
162-
return nil, fmt.Errorf("got content type header %q, expected %q", fullCType, mediatypes.ApplicationJSON)
163+
return nil, fmt.Errorf("got content type header %q, expected %q", fullCType, jsonContentType)
163164
}
164-
if cType != mediatypes.ApplicationJSON {
165-
return nil, fmt.Errorf("got content type %q, expected %q", cType, mediatypes.ApplicationJSON)
165+
if cType != jsonContentType {
166+
return nil, fmt.Errorf("got content type %q, expected %q", cType, jsonContentType)
166167
}
167168

168169
reply := new(serverReply)

0 commit comments

Comments
 (0)