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

mtime and mtime-nsecs multipart headers not sent in browser #2837

Closed
alanshaw opened this issue Feb 24, 2020 · 2 comments
Closed

mtime and mtime-nsecs multipart headers not sent in browser #2837

alanshaw opened this issue Feb 24, 2020 · 2 comments
Labels
pkg:http-client Issues related only to ipfs-http-client

Comments

@alanshaw
Copy link
Member

The code here essentially is doing the following:

const formData = new FormData()
formData.append(
  'file',
  new Blob([], {type: 'application/octet-stream'}),
  'file/path',
  {header:{mtime:5}}
)

const req = new Request('/test', { method: 'post', body: formData })
await req.text()

Output (tested in Firefox and Chrome):

"-----------------------------227935052110062039083523745638
Content-Disposition: form-data; name=\"file\"; filename=\"file/path\"
Content-Type: application/octet-stream

-----------------------------227935052110062039083523745638--
"

Missing mtime header. Worryingly, as far as I can see, there's no way to set custom multipart headers using the APIs we have in the browser.

The form-data module supports header so it's working in Node.js:

https://github.com/form-data/form-data/blob/d7026253e728af9568503dc3dc55cd1a566605e0/lib/form_data.js#L181-L191

Tests for metadata are skipped here since go-ipfs does not support this feature and the tests that use js-ipfs-http-client in js-ipfs are run from Node.js. This is why we haven't seen failing tests for it.

Maybe we need to test against js-ipfs too, if js-ipfs is going to support features like this before go-ipfs in the future.

I'm not sure how this comment got resolved, I thought I was getting déjà vu! ipfs-inactive/js-ipfs-http-client#1186 (comment)

@achingbrain achingbrain transferred this issue from ipfs-inactive/js-ipfs-http-client Mar 9, 2020
@achingbrain achingbrain added the pkg:http-client Issues related only to ipfs-http-client label Mar 9, 2020
@alanshaw
Copy link
Member Author

@achingbrain
Copy link
Member

Yes, we're sending mtime etc headers, now, phew.

Maybe we need to test against js-ipfs too, if js-ipfs is going to support features like this before go-ipfs in the future.

I've added this: https://github.com/ipfs/js-ipfs/blob/master/packages/ipfs/package.json#L47 so we should catch this sort of thing in future.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg:http-client Issues related only to ipfs-http-client
Projects
None yet
Development

No branches or pull requests

2 participants