Guest User

Untitled

a guest
Nov 18th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. const zlib = require('zlib');
  2. const response = "{}"
  3.  
  4. exports.handler = (event, context, callback) => {
  5. if (event.headers['Accept-Encoding'].contains("gzip")) {
  6. zlib.gzip(response, function(error, gzippedResponse) {
  7. if (error) callback(error);
  8. else callback(null, {
  9. "body": gzippedResponse.toString("base64"),
  10. "isBase64Encoded": true,
  11. "statusCode": 200,
  12. "headers": {
  13. "Content-Encoding": "gzip"
  14. }
  15. });
  16. }
  17. }
  18. else callback(null, {
  19. "body": response,
  20. "statusCode": 200,
  21. "headers": {}
  22. });
  23. }
Add Comment
Please, Sign In to add comment