| 13 | const { EvoMapProxy } = require('../src/proxy'); |
| 14 | |
| 15 | function rawPost(url, token, body, headers = {}) { |
| 16 | return new Promise((resolve, reject) => { |
| 17 | const u = new URL(url); |
| 18 | const payload = JSON.stringify(body || {}); |
| 19 | const req = http.request({ |
| 20 | hostname: u.hostname, |
| 21 | port: u.port, |
| 22 | path: u.pathname, |
| 23 | method: 'POST', |
| 24 | headers: { |
| 25 | 'Authorization': 'Bearer ' + token, |
| 26 | 'Content-Type': 'application/json', |
| 27 | 'Content-Length': Buffer.byteLength(payload), |
| 28 | ...headers, |
| 29 | }, |
| 30 | }, (res) => { |
| 31 | const chunks = []; |
| 32 | res.on('data', (c) => chunks.push(c)); |
| 33 | res.on('end', () => resolve({ |
| 34 | status: res.statusCode, |
| 35 | headers: res.headers, |
| 36 | body: Buffer.concat(chunks).toString(), |
| 37 | })); |
| 38 | }); |
| 39 | req.on('error', reject); |
| 40 | req.write(payload); |
| 41 | req.end(); |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | describe('POST /v1/responses — Codex/OpenAI passthrough', () => { |
| 46 | let server, baseUrl, token, captured; |