MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / sendIndex

Function sendIndex

javascript/selenium-webdriver/lib/test/fileserver.js:304–332  ·  view source on GitHub ↗

* Responds to a request for the file server's main index. * @param {!http.ServerRequest} request The request object. * @param {!http.ServerResponse} response The response object.

(request, response)

Source from the content-addressed store, hash-verified

302 * @param {!http.ServerResponse} response The response object.
303 */
304function sendIndex(request, response) {
305 // eslint-disable-next-line n/no-deprecated-api
306 var pathname = url.parse(request.url).pathname
307
308 var host = request.headers.host
309 if (!host) {
310 host = server.host()
311 }
312
313 var requestUrl = ['http://' + host + pathname].join('')
314
315 function createListEntry(path) {
316 var url = requestUrl + path
317 return ['<li><a href="', url, '">', path, '</a>'].join('')
318 }
319
320 var data = ['<!DOCTYPE html><h1>/</h1><hr/><ul>', createListEntry('common'), createListEntry('data')]
321 if (isDevMode()) {
322 data.push(createListEntry('javascript'))
323 }
324 data.push('</ul>')
325 data = data.join('')
326
327 response.writeHead(200, {
328 'Content-Type': 'text/html; charset=UTF-8',
329 'Content-Length': Buffer.byteLength(data, 'utf8'),
330 })
331 response.end(data)
332}
333
334/**
335 * Detects the hostname.

Callers

nothing calls this directly

Calls 5

createListEntryFunction · 0.85
isDevModeFunction · 0.85
joinMethod · 0.80
endMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected