OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 var fs = require("fs"); | 4 var fs = require("fs"); |
5 var http = require("http"); | 5 var http = require("http"); |
6 var https = require("https"); | 6 var https = require("https"); |
7 var path = require("path"); | 7 var path = require("path"); |
8 var parseURL = require("url").parse; | 8 var parseURL = require("url").parse; |
9 var Stream = require("stream").Transform; | 9 var Stream = require("stream").Transform; |
10 | 10 |
11 var remoteDebuggingPort = parseInt(process.env.REMOTE_DEBUGGING_PORT, 10) || 922
2; | 11 var remoteDebuggingPort = parseInt(process.env.REMOTE_DEBUGGING_PORT, 10) || 922
2; |
12 var serverPort = parseInt(process.env.PORT, 10) || 8090; | 12 var serverPort = parseInt(process.env.PORT, 10) || 8090; |
13 var devtoolsFolder = path.resolve(path.join(__dirname, "../..")); | 13 var devtoolsFolder = path.resolve(path.join(__dirname, "../..")); |
14 | 14 |
15 http.createServer(requestHandler).listen(serverPort); | 15 http.createServer(requestHandler).listen(serverPort); |
16 console.log(`Started hosted mode server at http://localhost:${serverPort}\n`); | 16 console.log(`Started hosted mode server at http://localhost:${serverPort}\n`); |
17 console.log("For info on using the hosted mode server, see our contributing docs
:"); | 17 console.log("For info on using the hosted mode server, see our contributing docs
:"); |
18 console.log("https://bit.ly/devtools-contribution-guide"); | 18 console.log("https://bit.ly/devtools-contribution-guide"); |
19 console.log("Tip: Look for the 'Hosted Mode Server Options' section"); | 19 console.log("Tip: Look for the 'Hosted Mode Server Options' section\n"); |
20 | 20 |
21 function requestHandler(request, response) | 21 function requestHandler(request, response) |
22 { | 22 { |
23 var filePath = parseURL(request.url).pathname; | 23 var filePath = parseURL(request.url).pathname; |
24 if (filePath === "/") { | 24 if (filePath === "/") { |
25 var landingURL = `http://localhost:${remoteDebuggingPort}#http://localho
st:${serverPort}/front_end/inspector.html?experiments=true`; | 25 var landingURL = `http://localhost:${remoteDebuggingPort}#http://localho
st:${serverPort}/front_end/inspector.html?experiments=true`; |
26 sendResponse(200, `<html>Please go to <a href="${landingURL}">${landingU
RL}</a></html>`); | 26 sendResponse(200, `<html>Please go to <a href="${landingURL}">${landingU
RL}</a></html>`); |
27 return; | 27 return; |
28 } | 28 } |
29 | 29 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 if (response.statusCode !== 200) { | 151 if (response.statusCode !== 200) { |
152 reject(new Error(`Request error: + ${response.statusCode}`)); | 152 reject(new Error(`Request error: + ${response.statusCode}`)); |
153 return; | 153 return; |
154 } | 154 } |
155 var body = new Stream(); | 155 var body = new Stream(); |
156 response.on("data", chunk => body.push(chunk)); | 156 response.on("data", chunk => body.push(chunk)); |
157 response.on("end", () => resolve(body.read())); | 157 response.on("end", () => resolve(body.read())); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
OLD | NEW |