MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / send

Method send

javascript/selenium-webdriver/http/index.js:118–166  ·  view source on GitHub ↗

@override

(httpRequest)

Source from the content-addressed store, hash-verified

116
117 /** @override */
118 send(httpRequest) {
119 let data
120
121 let headers = {}
122
123 if (httpRequest.headers) {
124 httpRequest.headers.forEach(function (value, name) {
125 headers[name] = value
126 })
127 }
128
129 headers['User-Agent'] = this.client_options['user-agent'] || USER_AGENT
130 headers['Content-Length'] = 0
131 if (httpRequest.method == 'POST' || httpRequest.method == 'PUT') {
132 data = JSON.stringify(httpRequest.data)
133 headers['Content-Length'] = Buffer.byteLength(data, 'utf8')
134 headers['Content-Type'] = 'application/json;charset=UTF-8'
135 }
136
137 let path = this.options_.path
138 if (path.endsWith('/') && httpRequest.path.startsWith('/')) {
139 path += httpRequest.path.substring(1)
140 } else {
141 path += httpRequest.path
142 }
143 // eslint-disable-next-line n/no-deprecated-api
144 let parsedPath = url.parse(path)
145
146 let options = {
147 agent: this.agent_ || null,
148 method: httpRequest.method,
149
150 auth: this.options_.auth,
151 hostname: this.options_.hostname,
152 port: this.options_.port,
153 protocol: this.options_.protocol,
154
155 path: parsedPath.path,
156 pathname: parsedPath.pathname,
157 search: parsedPath.search,
158 hash: parsedPath.hash,
159
160 headers,
161 }
162
163 return new Promise((fulfill, reject) => {
164 sendRequest(options, fulfill, reject, data, this.proxyOptions_)
165 })
166 }
167}
168
169/**

Callers 1

getWsUrlMethod · 0.95

Calls 3

sendRequestFunction · 0.85
forEachMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected