Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/selenium-webdriver/lib/http.js
2884 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
/**
19
* @fileoverview Defines an environment agnostic {@linkplain cmd.Executor
20
* command executor} that communicates with a remote end using JSON over HTTP.
21
*
22
* Clients should implement the {@link Client} interface, which is used by
23
* the {@link Executor} to send commands to the remote end.
24
*/
25
26
'use strict'
27
28
const path = require('node:path')
29
const cmd = require('./command')
30
const error = require('./error')
31
const logging = require('./logging')
32
const promise = require('./promise')
33
const { Session } = require('./session')
34
const webElement = require('./webelement')
35
const { isObject } = require('./util')
36
37
const log_ = logging.getLogger(`${logging.Type.DRIVER}.http`)
38
39
const getAttribute = requireAtom('get-attribute.js', '//javascript/selenium-webdriver/lib/atoms:get-attribute.js')
40
const isDisplayed = requireAtom('is-displayed.js', '//javascript/selenium-webdriver/lib/atoms:is-displayed.js')
41
const findElements = requireAtom('find-elements.js', '//javascript/selenium-webdriver/lib/atoms:find-elements.js')
42
43
/**
44
* @param {string} module
45
* @param {string} bazelTarget
46
* @return {!Function}
47
*/
48
function requireAtom(module, bazelTarget) {
49
try {
50
return require('./atoms/' + module)
51
} catch (ex) {
52
try {
53
const file = bazelTarget.slice(2).replace(':', '/')
54
log_.log(`../../../bazel-bin/${file}`)
55
return require(path.resolve(`../../../bazel-bin/${file}`))
56
} catch (ex2) {
57
log_.severe(ex2)
58
throw Error(
59
`Failed to import atoms module ${module}. If running in dev mode, you` +
60
` need to run \`bazel build ${bazelTarget}\` from the project` +
61
`root: ${ex}`,
62
)
63
}
64
}
65
}
66
67
/**
68
* Converts a headers map to a HTTP header block string.
69
* @param {!Map<string, string>} headers The map to convert.
70
* @return {string} The headers as a string.
71
*/
72
function headersToString(headers) {
73
const ret = []
74
headers.forEach(function (value, name) {
75
ret.push(`${name.toLowerCase()}: ${value}`)
76
})
77
return ret.join('\n')
78
}
79
80
/**
81
* Represents a HTTP request message. This class is a "partial" request and only
82
* defines the path on the server to send a request to. It is each client's
83
* responsibility to build the full URL for the final request.
84
* @final
85
*/
86
class Request {
87
/**
88
* @param {string} method The HTTP method to use for the request.
89
* @param {string} path The path on the server to send the request to.
90
* @param {Object=} opt_data This request's non-serialized JSON payload data.
91
*/
92
constructor(method, path, opt_data) {
93
this.method = /** string */ method
94
this.path = /** string */ path
95
this.data = /** Object */ opt_data
96
this.headers = /** !Map<string, string> */ new Map([['Accept', 'application/json; charset=utf-8']])
97
}
98
99
/** @override */
100
toString() {
101
let ret = `${this.method} ${this.path} HTTP/1.1\n`
102
ret += headersToString(this.headers) + '\n\n'
103
if (this.data) {
104
ret += JSON.stringify(this.data)
105
}
106
return ret
107
}
108
}
109
110
/**
111
* Represents a HTTP response message.
112
* @final
113
*/
114
class Response {
115
/**
116
* @param {number} status The response code.
117
* @param {!Object<string>} headers The response headers. All header names
118
* will be converted to lowercase strings for consistent lookups.
119
* @param {string} body The response body.
120
*/
121
constructor(status, headers, body) {
122
this.status = /** number */ status
123
this.body = /** string */ body
124
this.headers = /** !Map<string, string>*/ new Map()
125
for (let header in headers) {
126
this.headers.set(header.toLowerCase(), headers[header])
127
}
128
}
129
130
/** @override */
131
toString() {
132
let ret = `HTTP/1.1 ${this.status}\n${headersToString(this.headers)}\n\n`
133
if (this.body) {
134
ret += this.body
135
}
136
return ret
137
}
138
}
139
140
/** @enum {!Function} */
141
const Atom = {
142
GET_ATTRIBUTE: getAttribute,
143
IS_DISPLAYED: isDisplayed,
144
FIND_ELEMENTS: findElements,
145
}
146
147
function post(path) {
148
return resource('POST', path)
149
}
150
151
function del(path) {
152
return resource('DELETE', path)
153
}
154
155
function get(path) {
156
return resource('GET', path)
157
}
158
159
function resource(method, path) {
160
return { method: method, path: path }
161
}
162
163
/** @typedef {{method: string, path: string}} */
164
var CommandSpec
165
166
/** @typedef {function(!cmd.Command): !cmd.Command} */
167
var CommandTransformer
168
169
class InternalTypeError extends TypeError {}
170
171
/**
172
* @param {!cmd.Command} command The initial command.
173
* @param {Atom} atom The name of the atom to execute.
174
* @param params
175
* @return {!Command} The transformed command to execute.
176
*/
177
function toExecuteAtomCommand(command, atom, name, ...params) {
178
if (typeof atom !== 'function') {
179
throw new InternalTypeError('atom is not a function: ' + typeof atom)
180
}
181
182
return new cmd.Command(cmd.Name.EXECUTE_SCRIPT)
183
.setParameter('sessionId', command.getParameter('sessionId'))
184
.setParameter('script', `/* ${name} */return (${atom}).apply(null, arguments)`)
185
.setParameter(
186
'args',
187
params.map((param) => command.getParameter(param)),
188
)
189
}
190
191
/** @const {!Map<string, (CommandSpec|CommandTransformer)>} */
192
const W3C_COMMAND_MAP = new Map([
193
// Session management.
194
[cmd.Name.NEW_SESSION, post('/session')],
195
[cmd.Name.QUIT, del('/session/:sessionId')],
196
197
// Server status.
198
[cmd.Name.GET_SERVER_STATUS, get('/status')],
199
200
// timeouts
201
[cmd.Name.GET_TIMEOUT, get('/session/:sessionId/timeouts')],
202
[cmd.Name.SET_TIMEOUT, post('/session/:sessionId/timeouts')],
203
204
// Navigation.
205
[cmd.Name.GET_CURRENT_URL, get('/session/:sessionId/url')],
206
[cmd.Name.GET, post('/session/:sessionId/url')],
207
[cmd.Name.GO_BACK, post('/session/:sessionId/back')],
208
[cmd.Name.GO_FORWARD, post('/session/:sessionId/forward')],
209
[cmd.Name.REFRESH, post('/session/:sessionId/refresh')],
210
211
// Page inspection.
212
[cmd.Name.GET_PAGE_SOURCE, get('/session/:sessionId/source')],
213
[cmd.Name.GET_TITLE, get('/session/:sessionId/title')],
214
215
// Script execution.
216
[cmd.Name.EXECUTE_SCRIPT, post('/session/:sessionId/execute/sync')],
217
[cmd.Name.EXECUTE_ASYNC_SCRIPT, post('/session/:sessionId/execute/async')],
218
219
// Frame selection.
220
[cmd.Name.SWITCH_TO_FRAME, post('/session/:sessionId/frame')],
221
[cmd.Name.SWITCH_TO_FRAME_PARENT, post('/session/:sessionId/frame/parent')],
222
223
// Window management.
224
[cmd.Name.GET_CURRENT_WINDOW_HANDLE, get('/session/:sessionId/window')],
225
[cmd.Name.CLOSE, del('/session/:sessionId/window')],
226
[cmd.Name.SWITCH_TO_WINDOW, post('/session/:sessionId/window')],
227
[cmd.Name.SWITCH_TO_NEW_WINDOW, post('/session/:sessionId/window/new')],
228
[cmd.Name.GET_WINDOW_HANDLES, get('/session/:sessionId/window/handles')],
229
[cmd.Name.GET_WINDOW_RECT, get('/session/:sessionId/window/rect')],
230
[cmd.Name.SET_WINDOW_RECT, post('/session/:sessionId/window/rect')],
231
[cmd.Name.MAXIMIZE_WINDOW, post('/session/:sessionId/window/maximize')],
232
[cmd.Name.MINIMIZE_WINDOW, post('/session/:sessionId/window/minimize')],
233
[cmd.Name.FULLSCREEN_WINDOW, post('/session/:sessionId/window/fullscreen')],
234
235
// Actions.
236
[cmd.Name.ACTIONS, post('/session/:sessionId/actions')],
237
[cmd.Name.CLEAR_ACTIONS, del('/session/:sessionId/actions')],
238
[cmd.Name.PRINT_PAGE, post('/session/:sessionId/print')],
239
240
// Locating elements.
241
[cmd.Name.GET_ACTIVE_ELEMENT, get('/session/:sessionId/element/active')],
242
[cmd.Name.FIND_ELEMENT, post('/session/:sessionId/element')],
243
[cmd.Name.FIND_ELEMENTS, post('/session/:sessionId/elements')],
244
[
245
cmd.Name.FIND_ELEMENTS_RELATIVE,
246
(cmd) => {
247
return toExecuteAtomCommand(cmd, Atom.FIND_ELEMENTS, 'findElements', 'args')
248
},
249
],
250
[cmd.Name.FIND_CHILD_ELEMENT, post('/session/:sessionId/element/:id/element')],
251
[cmd.Name.FIND_CHILD_ELEMENTS, post('/session/:sessionId/element/:id/elements')],
252
// Element interaction.
253
[cmd.Name.GET_ELEMENT_TAG_NAME, get('/session/:sessionId/element/:id/name')],
254
[cmd.Name.GET_DOM_ATTRIBUTE, get('/session/:sessionId/element/:id/attribute/:name')],
255
[
256
cmd.Name.GET_ELEMENT_ATTRIBUTE,
257
(cmd) => {
258
return toExecuteAtomCommand(cmd, Atom.GET_ATTRIBUTE, 'getAttribute', 'id', 'name')
259
},
260
],
261
[cmd.Name.GET_ELEMENT_PROPERTY, get('/session/:sessionId/element/:id/property/:name')],
262
[cmd.Name.GET_ELEMENT_VALUE_OF_CSS_PROPERTY, get('/session/:sessionId/element/:id/css/:propertyName')],
263
[cmd.Name.GET_ELEMENT_RECT, get('/session/:sessionId/element/:id/rect')],
264
[cmd.Name.CLEAR_ELEMENT, post('/session/:sessionId/element/:id/clear')],
265
[cmd.Name.CLICK_ELEMENT, post('/session/:sessionId/element/:id/click')],
266
[cmd.Name.SEND_KEYS_TO_ELEMENT, post('/session/:sessionId/element/:id/value')],
267
[cmd.Name.GET_ELEMENT_TEXT, get('/session/:sessionId/element/:id/text')],
268
[cmd.Name.GET_COMPUTED_ROLE, get('/session/:sessionId/element/:id/computedrole')],
269
[cmd.Name.GET_COMPUTED_LABEL, get('/session/:sessionId/element/:id/computedlabel')],
270
[cmd.Name.IS_ELEMENT_ENABLED, get('/session/:sessionId/element/:id/enabled')],
271
[cmd.Name.IS_ELEMENT_SELECTED, get('/session/:sessionId/element/:id/selected')],
272
273
[
274
cmd.Name.IS_ELEMENT_DISPLAYED,
275
(cmd) => {
276
return toExecuteAtomCommand(cmd, Atom.IS_DISPLAYED, 'isDisplayed', 'id')
277
},
278
],
279
280
// Cookie management.
281
[cmd.Name.GET_ALL_COOKIES, get('/session/:sessionId/cookie')],
282
[cmd.Name.ADD_COOKIE, post('/session/:sessionId/cookie')],
283
[cmd.Name.DELETE_ALL_COOKIES, del('/session/:sessionId/cookie')],
284
[cmd.Name.GET_COOKIE, get('/session/:sessionId/cookie/:name')],
285
[cmd.Name.DELETE_COOKIE, del('/session/:sessionId/cookie/:name')],
286
287
// Alert management.
288
[cmd.Name.ACCEPT_ALERT, post('/session/:sessionId/alert/accept')],
289
[cmd.Name.DISMISS_ALERT, post('/session/:sessionId/alert/dismiss')],
290
[cmd.Name.GET_ALERT_TEXT, get('/session/:sessionId/alert/text')],
291
[cmd.Name.SET_ALERT_TEXT, post('/session/:sessionId/alert/text')],
292
293
// Screenshots.
294
[cmd.Name.SCREENSHOT, get('/session/:sessionId/screenshot')],
295
[cmd.Name.TAKE_ELEMENT_SCREENSHOT, get('/session/:sessionId/element/:id/screenshot')],
296
297
// Shadow Root
298
[cmd.Name.GET_SHADOW_ROOT, get('/session/:sessionId/element/:id/shadow')],
299
[cmd.Name.FIND_ELEMENT_FROM_SHADOWROOT, post('/session/:sessionId/shadow/:id/element')],
300
[cmd.Name.FIND_ELEMENTS_FROM_SHADOWROOT, post('/session/:sessionId/shadow/:id/elements')],
301
// Log extensions.
302
[cmd.Name.GET_LOG, post('/session/:sessionId/se/log')],
303
[cmd.Name.GET_AVAILABLE_LOG_TYPES, get('/session/:sessionId/se/log/types')],
304
305
// Server Extensions
306
[cmd.Name.UPLOAD_FILE, post('/session/:sessionId/se/file')],
307
308
// Virtual Authenticator
309
[cmd.Name.ADD_VIRTUAL_AUTHENTICATOR, post('/session/:sessionId/webauthn/authenticator')],
310
[cmd.Name.REMOVE_VIRTUAL_AUTHENTICATOR, del('/session/:sessionId/webauthn/authenticator/:authenticatorId')],
311
[cmd.Name.ADD_CREDENTIAL, post('/session/:sessionId/webauthn/authenticator/:authenticatorId/credential')],
312
[cmd.Name.GET_CREDENTIALS, get('/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials')],
313
[
314
cmd.Name.REMOVE_CREDENTIAL,
315
del('/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials/:credentialId'),
316
],
317
[cmd.Name.REMOVE_ALL_CREDENTIALS, del('/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials')],
318
[cmd.Name.SET_USER_VERIFIED, post('/session/:sessionId/webauthn/authenticator/:authenticatorId/uv')],
319
320
[cmd.Name.GET_DOWNLOADABLE_FILES, get('/session/:sessionId/se/files')],
321
[cmd.Name.DOWNLOAD_FILE, post(`/session/:sessionId/se/files`)],
322
[cmd.Name.DELETE_DOWNLOADABLE_FILES, del(`/session/:sessionId/se/files`)],
323
324
// Federated Credential Management Command
325
[cmd.Name.CANCEL_DIALOG, post(`/session/:sessionId/fedcm/canceldialog`)],
326
[cmd.Name.SELECT_ACCOUNT, post(`/session/:sessionId/fedcm/selectaccount`)],
327
[cmd.Name.GET_FEDCM_TITLE, get(`/session/:sessionId/fedcm/gettitle`)],
328
[cmd.Name.GET_FEDCM_DIALOG_TYPE, get('/session/:sessionId/fedcm/getdialogtype')],
329
[cmd.Name.SET_DELAY_ENABLED, post(`/session/:sessionId/fedcm/setdelayenabled`)],
330
[cmd.Name.RESET_COOLDOWN, post(`/session/:sessionId/fedcm/resetcooldown`)],
331
[cmd.Name.CLICK_DIALOG_BUTTON, post(`/session/:sessionId/fedcm/clickdialogbutton`)],
332
[cmd.Name.GET_ACCOUNTS, get(`/session/:sessionId/fedcm/accountlist`)],
333
])
334
335
/**
336
* Handles sending HTTP messages to a remote end.
337
*
338
* @interface
339
*/
340
class Client {
341
/**
342
* Sends a request to the server. The client will automatically follow any
343
* redirects returned by the server, fulfilling the returned promise with the
344
* final response.
345
*
346
* @param {!Request} httpRequest The request to send.
347
* @return {!Promise<Response>} A promise that will be fulfilled with the
348
* server's response.
349
*/
350
send(httpRequest) {}
351
}
352
353
/**
354
* @param {Map<string, CommandSpec>} customCommands
355
* A map of custom command definitions.
356
* @param {!cmd.Command} command The command to resolve.
357
* @return {!Request} A promise that will resolve with the
358
* command to execute.
359
*/
360
function buildRequest(customCommands, command) {
361
log_.finest(() => `Translating command: ${command.getName()}`)
362
let spec = customCommands && customCommands.get(command.getName())
363
if (spec) {
364
return toHttpRequest(spec)
365
}
366
367
spec = W3C_COMMAND_MAP.get(command.getName())
368
if (typeof spec === 'function') {
369
log_.finest(() => `Transforming command for W3C: ${command.getName()}`)
370
let newCommand = spec(command)
371
return buildRequest(customCommands, newCommand)
372
} else if (spec) {
373
return toHttpRequest(spec)
374
}
375
throw new error.UnknownCommandError('Unrecognized command: ' + command.getName())
376
377
/**
378
* @param {CommandSpec} resource
379
* @return {!Request}
380
*/
381
function toHttpRequest(resource) {
382
log_.finest(() => `Building HTTP request: ${JSON.stringify(resource)}`)
383
let parameters = command.getParameters()
384
let path = buildPath(resource.path, parameters)
385
return new Request(resource.method, path, parameters)
386
}
387
}
388
389
const CLIENTS = /** !WeakMap<!Executor, !(Client|IThenable<!Client>)> */ new WeakMap()
390
391
/**
392
* A command executor that communicates with the server using JSON over HTTP.
393
*
394
* By default, each instance of this class will use the legacy wire protocol
395
* from [Selenium project][json]. The executor will automatically switch to the
396
* [W3C wire protocol][w3c] if the remote end returns a compliant response to
397
* a new session command.
398
*
399
* [json]: https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol
400
* [w3c]: https://w3c.github.io/webdriver/webdriver-spec.html
401
*
402
* @implements {cmd.Executor}
403
*/
404
class Executor {
405
/**
406
* @param {!(Client|IThenable<!Client>)} client The client to use for sending
407
* requests to the server, or a promise-like object that will resolve
408
* to the client.
409
*/
410
constructor(client) {
411
CLIENTS.set(this, client)
412
413
/** @private {Map<string, CommandSpec>} */
414
this.customCommands_ = null
415
416
/** @private {!logging.Logger} */
417
this.log_ = logging.getLogger(`${logging.Type.DRIVER}.http.Executor`)
418
}
419
420
/**
421
* Defines a new command for use with this executor. When a command is sent,
422
* the {@code path} will be preprocessed using the command's parameters; any
423
* path segments prefixed with ":" will be replaced by the parameter of the
424
* same name. For example, given "/person/:name" and the parameters
425
* "{name: 'Bob'}", the final command path will be "/person/Bob".
426
*
427
* @param {string} name The command name.
428
* @param {string} method The HTTP method to use when sending this command.
429
* @param {string} path The path to send the command to, relative to
430
* the WebDriver server's command root and of the form
431
* "/path/:variable/segment".
432
*/
433
defineCommand(name, method, path) {
434
if (!this.customCommands_) {
435
this.customCommands_ = new Map()
436
}
437
this.customCommands_.set(name, { method, path })
438
}
439
440
/** @override */
441
async execute(command) {
442
let request = buildRequest(this.customCommands_, command)
443
this.log_.finer(() => `>>> ${request.method} ${request.path}`)
444
445
let client = CLIENTS.get(this)
446
if (promise.isPromise(client)) {
447
client = await client
448
CLIENTS.set(this, client)
449
}
450
451
let response = await client.send(request)
452
this.log_.finer(() => `>>>\n${request}\n<<<\n${response}`)
453
454
let httpResponse = /** @type {!Response} */ (response)
455
456
let { isW3C, value } = parseHttpResponse(command, httpResponse)
457
458
if (command.getName() === cmd.Name.NEW_SESSION) {
459
if (!value || !value.sessionId) {
460
throw new error.WebDriverError(`Unable to parse new session response: ${response.body}`)
461
}
462
463
// The remote end is a W3C compliant server if there is no `status`
464
// field in the response.
465
if (command.getName() === cmd.Name.NEW_SESSION) {
466
this.w3c = this.w3c || isW3C
467
}
468
469
// No implementations use the `capabilities` key yet...
470
let capabilities = value.capabilities || value.value
471
return new Session(/** @type {{sessionId: string}} */ (value).sessionId, capabilities)
472
}
473
474
return typeof value === 'undefined' ? null : value
475
}
476
}
477
478
/**
479
* @param {string} str .
480
* @return {?} .
481
*/
482
function tryParse(str) {
483
try {
484
return JSON.parse(str)
485
/*eslint no-unused-vars: "off"*/
486
} catch (ignored) {
487
// Do nothing.
488
}
489
}
490
491
/**
492
* Callback used to parse {@link Response} objects from a
493
* {@link HttpClient}.
494
*
495
* @param {!cmd.Command} command The command the response is for.
496
* @param {!Response} httpResponse The HTTP response to parse.
497
* @return {{isW3C: boolean, value: ?}} An object describing the parsed
498
* response. This object will have two fields: `isW3C` indicates whether
499
* the response looks like it came from a remote end that conforms with the
500
* W3C WebDriver spec, and `value`, the actual response value.
501
* @throws {WebDriverError} If the HTTP response is an error.
502
*/
503
function parseHttpResponse(command, httpResponse) {
504
if (httpResponse.status < 200) {
505
// This should never happen, but throw the raw response so users report it.
506
throw new error.WebDriverError(`Unexpected HTTP response:\n${httpResponse}`)
507
}
508
509
let parsed = tryParse(httpResponse.body)
510
511
if (parsed && typeof parsed === 'object') {
512
let value = parsed.value
513
let isW3C = isObject(value) && typeof parsed.status === 'undefined'
514
515
if (!isW3C) {
516
error.checkLegacyResponse(parsed)
517
518
// Adjust legacy new session responses to look like W3C to simplify
519
// later processing.
520
if (command.getName() === cmd.Name.NEW_SESSION) {
521
value = parsed
522
}
523
} else if (httpResponse.status > 399) {
524
error.throwDecodedError(value)
525
}
526
527
return { isW3C, value }
528
}
529
530
if (parsed !== undefined) {
531
return { isW3C: false, value: parsed }
532
}
533
534
let value = httpResponse.body.replace(/\r\n/g, '\n')
535
536
// 404 represents an unknown command; anything else > 399 is a generic unknown
537
// error.
538
if (httpResponse.status === 404) {
539
throw new error.UnsupportedOperationError(command.getName() + ': ' + value)
540
} else if (httpResponse.status >= 400) {
541
throw new error.WebDriverError(value)
542
}
543
544
return { isW3C: false, value: value || null }
545
}
546
547
/**
548
* Builds a fully qualified path using the given set of command parameters. Each
549
* path segment prefixed with ':' will be replaced by the value of the
550
* corresponding parameter. All parameters spliced into the path will be
551
* removed from the parameter map.
552
* @param {string} path The original resource path.
553
* @param {!Object<*>} parameters The parameters object to splice into the path.
554
* @return {string} The modified path.
555
*/
556
function buildPath(path, parameters) {
557
let pathParameters = path.match(/\/:(\w+)\b/g)
558
if (pathParameters) {
559
for (let i = 0; i < pathParameters.length; ++i) {
560
let key = pathParameters[i].substring(2) // Trim the /:
561
if (key in parameters) {
562
let value = parameters[key]
563
if (webElement.isId(value)) {
564
// When inserting a WebElement into the URL, only use its ID value,
565
// not the full JSON.
566
value = webElement.extractId(value)
567
}
568
path = path.replace(pathParameters[i], '/' + value)
569
delete parameters[key]
570
} else {
571
throw new error.InvalidArgumentError('Missing required parameter: ' + key)
572
}
573
}
574
}
575
return path
576
}
577
578
// PUBLIC API
579
580
module.exports = {
581
Executor,
582
Client,
583
Request,
584
Response,
585
// Exported for testing.
586
buildPath,
587
}
588
589