(url: string, postData: any)
| 15 | |
| 16 | // @notTest |
| 17 | const httpPost = (url: string, postData: any) => { |
| 18 | if (!url.startsWith("http")) url = "http://" + url |
| 19 | let req = request(url, { |
| 20 | method: "POST", |
| 21 | // port: 80, |
| 22 | // path: '/upload', |
| 23 | headers: { |
| 24 | 'Content-Type': 'application/json', |
| 25 | 'Content-Length': Buffer.byteLength(postData), |
| 26 | 'Content-Encoding': 'gzip' |
| 27 | } |
| 28 | }, (res: IncomingMessage) => { |
| 29 | res.setEncoding('utf8'); |
| 30 | res.on("data", (chunk) => LOGD(chunk)) |
| 31 | }) |
| 32 | req.write(postData) |
| 33 | } |
| 34 | |
| 35 | export { httpGet, httpPost } |
| 36 |