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

Function URL with Response Streaming does not support Content-Encoding #96

Open
paya-cz opened this issue Feb 2, 2024 · 0 comments
Open

Comments

@paya-cz
Copy link

paya-cz commented Feb 2, 2024

If I compress my response using gzip and set a proper Content-Encoding response header, it appears like Function URL will decompress my response on-the-fly, remove the Content-Encoding header, and pass down the uncompressed response stream. This is wasteful and unnecessary.

const pipeline = require("util").promisify(require("stream").pipeline);
const { Readable } = require("stream");
const zlib = require('zlib');

exports.handler = awslambda.streamifyResponse(async (event,
responseStream, context) => {
    responseStream = awslambda.HttpResponseStream.from(responseStream, {
      statusCode: 200,
      headers: {
       'content-encoding': 'gzip',
       'content-type': 'text/plain',
      }
    });

    await pipeline(
      Readable.from(zlib.gzipSync('hello world')),
      responseStream,
    );
});

See here - the response is uncompressed, with Content-Encoding header stripped:

ss

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