forwardemail / forwardemail/superagent

how to send gzip compressed body superagent

Open
#1,751 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
16.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

```typescript
it(`should do request with gzip`, async () => {
const RESPONSE_BODY = { hello: 'world' };
server.post('/encrypt/body/:id', (_req, res) => res.json(RESPONSE_BODY));
const data = { test: 'json' };
const _data = zlib.gzipSync(Buffer.from(JSON.stringify(data)));

await request
.post(URI)
.set('Content-Encoding', 'gzip')
.set('Content-Type', 'application/json')
.set('Content-Length', _data.length.toString())
.set('Accept-Encoding', 'gzip')
.send(_data);
});
```

The test code was written as above.
However, an internal error occurs on the server side...

But, When the server code is the same, the test using curl works fine.
```bash
echo '{"test":"json"}' | gzip > test_body.gz
curl -v -i -X post http://localhost:8080/gzip -H 'content-encoding: gzip' -H 'content-type: application/json' --data-binary @test_body.gz
```
I want you to give me a hint to solve this...

(with restify)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.