@@ -19,8 +19,6 @@ import (
19
19
20
20
"github.com/blang/semver"
21
21
"github.com/tebeka/selenium/firefox"
22
- "github.com/tebeka/selenium/http/headers"
23
- "github.com/tebeka/selenium/http/mediatypes"
24
22
"github.com/tebeka/selenium/log"
25
23
)
26
24
@@ -61,15 +59,18 @@ type remoteWD struct {
61
59
// server.
62
60
var HTTPClient = http .DefaultClient
63
61
62
+ // jsonContentType is JSON content type.
63
+ const jsonContentType = "application/json"
64
+
64
65
func newRequest (method string , url string , data []byte ) (* http.Request , error ) {
65
66
request , err := http .NewRequest (method , url , bytes .NewBuffer (data ))
66
67
if err != nil {
67
68
return nil , err
68
69
}
69
70
if data != nil {
70
- request .Header .Add (headers . ContentType , mediatypes . ApplicationJSONUtf8 )
71
+ request .Header .Add ("Content-Type" , jsonContentType )
71
72
}
72
- request .Header .Add (headers . Accept , mediatypes . ApplicationJSON )
73
+ request .Header .Add (" Accept" , jsonContentType )
73
74
74
75
return request , nil
75
76
}
@@ -150,19 +151,19 @@ func executeCommand(method, url string, data []byte) (json.RawMessage, error) {
150
151
buf = prettyBuf .Bytes ()
151
152
}
152
153
}
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 )
154
155
}
155
156
if err != nil {
156
157
return nil , errors .New (response .Status )
157
158
}
158
159
159
- fullCType := response .Header .Get (headers . ContentType )
160
+ fullCType := response .Header .Get ("Content-Type" )
160
161
cType , _ , err := mime .ParseMediaType (fullCType )
161
162
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 )
163
164
}
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 )
166
167
}
167
168
168
169
reply := new (serverReply )
0 commit comments