You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Non Uint32Array binary data does not set the CloudEvent's data_base64 value #491
When binary data, e.. Buffer or Uint8Array, is not converted to Uint32Array before being set as a CloudEvent's data, the data_base64 will not be set because isBinary() detection fails. This results in structured mode to go out of spec by not having the expected data_base64 attribute but instead include an unexpected data object.
If we convert the Buffer to Uint32Array and set as CloudEvent's data, then binary mode message body will contain wrong byte sequence as it will be that of Uint32Array rather than the expected Uint8Array. This can be overcome by wrapping the body from HTTP.binary() with Buffer.from(body) again before feeding it axios(). Also, Uint32Array binary data in binary mode does not work with the provided emitterFor() as the req.write() only allows Buffer or Uint8Array.
Expected Behavior
We should be able to pass TypedArray directly as data and both the structured and binary modes should create valid bodies that matches the spec.
Activity
fix: allow `Uint16|8Array` for binary data
lance commentedon Jun 14, 2022
Hi @matthewchngshopback thanks for opening this issue. I have applied a fix in #494 - can you please verify that it addresses your use case?
fix: allow `TypedArray` for binary data (#494)
matthewchngshopback commentedon Jun 20, 2022
@lance Yes, this fix addresses all the issues described. Thanks very much. What do you think the ETA is for 6.0.2?
lance commentedon Jun 20, 2022
@matthewchngshopback We can probably bump a release this week.
lance commentedon Jun 21, 2022
Done