(url, token)
| 10 | const { ProxyHttpServer } = require('../src/proxy/server/http'); |
| 11 | |
| 12 | function rawRequest(url, token) { |
| 13 | return new Promise((resolve, reject) => { |
| 14 | const u = new URL(url); |
| 15 | const req = http.request({ |
| 16 | hostname: u.hostname, |
| 17 | port: u.port, |
| 18 | path: u.pathname, |
| 19 | method: 'POST', |
| 20 | headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'Content-Length': 2 }, |
| 21 | }, (res) => { |
| 22 | const chunks = []; |
| 23 | res.on('data', (c) => chunks.push(c)); |
| 24 | res.on('end', () => resolve({ |
| 25 | status: res.statusCode, |
| 26 | headers: res.headers, |
| 27 | body: Buffer.concat(chunks).toString(), |
| 28 | })); |
| 29 | }); |
| 30 | req.on('error', reject); |
| 31 | req.write('{}'); |
| 32 | req.end(); |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | describe('ProxyHttpServer streaming pass-through', () => { |
| 37 | let server, baseUrl, token; |
no outgoing calls
no test coverage detected