Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to send gzip compressed body superagent #1751

Open
0Ams opened this issue Nov 14, 2022 · 0 comments
Open

how to send gzip compressed body superagent #1751

0Ams opened this issue Nov 14, 2022 · 0 comments

Comments

@0Ams
Copy link

0Ams commented Nov 14, 2022

  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.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant