-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ArrayBuffer request bodies #1776
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I think @na-- and I agreed upon just supporting ArrayBuffer for now. The Support for Int8Array(for example) seemed a little funky and at least for an MVP it is fine especially if we can error out to the user correctly.
Unfortunately, as you have noticed if someone provides Int8Array
it enters the map[string]interface{}
case with 0 keys so changing the error in the default
won't be sufficient. IMO there is no case where this is what the user wanted - so we can error on that one as well (possibly in the handleObjectBody
)?
The map[string]goja.Value
is only used from the SubmitForm
code it seems? Is there a case where we could want to submit a form with no data? I think not, I think it needs at least some info inside of it or am I wrong?
@mstoykov I don't think it would be safe to error out in that case, as we have no way to determine whether the user passed a typed array or an empty object (that I can see). If anything it should probably be logged as a warning, but given that we can't distinguish between those scenarios I'm inclined to leave it as is. @na-- What do you think? |
Hmm it'd have been nice if we could prevent footguns like that, but if there doesn't seem to be a good way to differentiate the typed arrays from other potential arguments, I'm not sure if there's anything we can do about it 🤷♂️ @mstoykov, goja seems to have custom Other than that, the code of the PR mostly LGTM. I'd only advise moving the test to its own standalone function, I don't see why we have to cram it into the already huge composite |
What do you propose they are exported to? ArrayBuffer? |
b16ea1c
to
c51e61e
Compare
Codecov Report
@@ Coverage Diff @@
## master #1776 +/- ##
==========================================
- Coverage 71.43% 71.42% -0.01%
==========================================
Files 178 178
Lines 13777 13783 +6
==========================================
+ Hits 9841 9845 +4
Misses 3323 3323
- Partials 613 615 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
No, their constituent types, see this |
c51e61e
to
6c40775
Compare
This is part of #1020, just for supporting
ArrayBuffer
request bodies. It works fine for submitting binary data fromopen()
, e.g.:It should probably have much more tests, but let me know what other scenarios we should cover. All the other typed arrays?
I wasn't able to get it to work with submitting the typed array itself instead of the
ArrayBuffer
, i.e. submittingarr
instead ofarr.buffer
above (as mentioned here). Goja'sExport()
on it returns an emptymap[string]interface{}{}
, so I couldn't get theArrayBuffer
from it. We should probably raise a warning in that case, unless we can work around it.