fs: report correct path when EEXIST
[platform/upstream/nodejs.git] / deps / npm / node_modules / request / tests / ssl / ca / server.js
1 var fs = require("fs")
2 var https = require("https")
3 var options = { key: fs.readFileSync("./server.key")
4               , cert: fs.readFileSync("./server.crt") }
5
6 var server = https.createServer(options, function (req, res) {
7   res.writeHead(200)
8   res.end()
9   server.close()
10 })
11 server.listen(1337)
12
13 var ca = fs.readFileSync("./ca.crt")
14 var agent = new https.Agent({ host: "localhost", port: 1337, ca: ca })
15
16 https.request({ host: "localhost"
17               , method: "HEAD"
18               , port: 1337
19               , headers: { host: "testing.request.mikealrogers.com" }
20               , agent: agent
21               , ca: [ ca ]
22               , path: "/" }, function (res) {
23   if (res.client.authorized) {
24     console.log("node test: OK")
25   } else {
26     throw new Error(res.client.authorizationError)
27   }
28 }).end()