Skip to content
Myr

fix(lambda@edge): add bodyEncoding property for base64 response (#1949)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Add bodyEncoding property for base64 response in Lambda@Edge adapter * run format:fix

authored by mosle · committed by GitHub · parent 34a7ada · Browse files · 2 files+37 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+37 added−0 removed

  • tests:+36 added−0 removed
  • other:+1 added−0 removed

2 files+37 added−0 removed

modified:runtime_tests/lambda-edge/index.test.ts+36 added
1094 unmodified lines
1095 })10961097 expect(called).toBe(true)1098 })10991100 it('Should return a response where bodyEncoding is "base64" with binary', async () => {1101 const event = {1102 Records: [1103 {1104 cf: {1105 config: {1106 distributionDomainName: 'example.com',1107 distributionId: 'EXAMPLE123',1108 eventType: 'viewer-request',1109 requestId: 'exampleRequestId',1110 },1111 request: {1112 clientIp: '123.123.123.123',1113 headers: {1114 host: [1115 {1116 key: 'Host',1117 value: 'example.com',1118 },1119 ],1120 },1121 method: 'GET',1122 querystring: '',1123 uri: '/binary',1124 },1125 },1126 },1127 ],1128 }11291130 const response = await handler(event)11311132 expect(response.body).toBe('RmFrZSBJbWFnZQ==') // base64 encoded "Fake Image"1133 expect(response.bodyEncoding).toBe('base64')1134 })1135})
modified:src/adapter/lambda-edge/handler.ts+1 added