Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix(http-server): properly stream UInt8Array
Browse files Browse the repository at this point in the history
make sure that UInt8Arrays are converted to Buffer so Hapi properly sends them as binary
  • Loading branch information
hannahhoward committed Apr 8, 2021
1 parent 5f74f36 commit 83fdf63
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/interface-ipfs-core/src/dag/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ module.exports = (common, options) => {
expect(result.value).to.deep.equal(buf)
})

it('should be able to get a dag-cbor node with the identity hash', async() => {
it('should be able to get a dag-cbor node with the identity hash', async () => {
const identityData = uint8ArrayFromString('A16461736466190144', 'base16upper')
const identityHash = await multihashing(identityData, 'identity')
const identityCID = new CID(1, 'dag-cbor', identityHash)
const result = await ipfs.dag.get(identityCID)
expect(result.value).to.deep.equal({"asdf":324})
expect(result.value).to.deep.equal({ asdf: 324 })
})

it('should throw error for invalid string CID input', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-server/src/api/resources/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ exports.get = {
throw Boom.notFound('Block was unwanted before it could be remotely retrieved')
}

return h.response(block.data).header('X-Stream-Output', '1')
return h.response(Buffer.from(block.data.buffer)).header('X-Stream-Output', '1')
}
}
exports.put = {
Expand Down

0 comments on commit 83fdf63

Please sign in to comment.