|
1 | | -// Copyright Joyent, Inc. and other Node contributors. |
2 | | -// |
3 | | -// Permission is hereby granted, free of charge, to any person obtaining a |
4 | | -// copy of this software and associated documentation files (the |
5 | | -// "Software"), to deal in the Software without restriction, including |
6 | | -// without limitation the rights to use, copy, modify, merge, publish, |
7 | | -// distribute, sublicense, and/or sell copies of the Software, and to permit |
8 | | -// persons to whom the Software is furnished to do so, subject to the |
9 | | -// following conditions: |
10 | | -// |
11 | | -// The above copyright notice and this permission notice shall be included |
12 | | -// in all copies or substantial portions of the Software. |
13 | | -// |
14 | | -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
15 | | -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
16 | | -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
17 | | -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
18 | | -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
19 | | -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
20 | | -// USE OR OTHER DEALINGS IN THE SOFTWARE. |
21 | | - |
22 | 1 | 'use strict'; |
23 | 2 | const common = require('../common'); |
24 | 3 | const assert = require('assert'); |
25 | 4 | const http = require('http'); |
26 | 5 |
|
27 | | -if (!common.isLinux) |
28 | | - common.skip(); |
29 | | - |
30 | | -const abstractSocket = '\0abstract'; |
31 | | - |
32 | | -let resStatus; |
33 | | - |
34 | | -const server = http.createServer((req, res) => { |
35 | | - assert.strictEqual(req.method, 'POST'); |
36 | | - |
37 | | - req.resume(); |
38 | | - |
39 | | - req.on('end', () => { |
40 | | - res.writeHead(200, { 'Content-Type': 'text/plain' }); |
41 | | - res.end(); |
42 | | - }); |
43 | | -}); |
44 | | -server.listen(abstractSocket); |
45 | | - |
46 | | -server.on('listening', () => { |
47 | | - makeRequest(); |
48 | | -}); |
49 | | - |
50 | | -function makeRequest() { |
51 | | - const req = http.request({ |
52 | | - path: '/', |
53 | | - method: 'POST', |
54 | | - socketPath: abstractSocket, |
55 | | - }); |
56 | | - |
57 | | - req.end(); |
58 | | - |
59 | | - req.on('response', (res) => { |
60 | | - resStatus = res.statusCode; |
61 | | - |
62 | | - res.resume(); |
63 | | - res.on('end', () => { |
64 | | - server.close(); |
65 | | - }); |
66 | | - }); |
67 | | -} |
68 | | - |
69 | | -process.on('exit', () => { |
70 | | - assert.strictEqual(resStatus, 200); |
71 | | -}); |
| 6 | +if (!common.isLinux) common.skip(); |
| 7 | + |
| 8 | +const server = http.createServer( |
| 9 | + common.mustCall((req, res) => { |
| 10 | + res.end('ok'); |
| 11 | + }) |
| 12 | +); |
| 13 | + |
| 14 | +server.listen( |
| 15 | + '\0abstract', |
| 16 | + common.mustCall(() => { |
| 17 | + http.get( |
| 18 | + { |
| 19 | + socketPath: server.address(), |
| 20 | + }, |
| 21 | + common.mustCall((res) => { |
| 22 | + assert.strictEqual(res.statusCode, 200); |
| 23 | + server.close(); |
| 24 | + }) |
| 25 | + ); |
| 26 | + }) |
| 27 | +); |
0 commit comments