-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[IOS] "fetch + FormData" create the Content-Type with a boundary wrapped with delimiter " #7564
Comments
Can you reproduce this problem on a small sample app with a rnplay.org link? |
Fix for some firewall with ModSecurity rules for MULTIPART_STRICT_ERROR, namely MULTIPART_BOUNDARY_QUOTED.
@lacker @XuChangZJU I happened to have the same issue. It happened only on some servers where 'ModSecurity' is enabled, and
to
In NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=\"%@\"", _boundary]; when i change to NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", _boundary]; then compiled then run and its working perfect,I have made pull request too |
not work if boundary include slash
jshttp/media-typer#5
may the quote is necessary |
@unordered I'm having the same issue, any workaround for that until this is resolved? |
@unordered Thanks! I +1ed it before, just was wondering if we have some client side work around until // HACK - react-native generates FormData with an invalid boundary that might contain '/'
// we need to wrap the boundary value with quotes to fix it
// TODO - remove this when react-native releases the fix
var re = /^multipart\/form-data.\s?boundary=['"]?(.*?)['"]?$/i;
app.use(function (req, res, next) {
var contentType = req.headers['content-type'];
var match = re.exec(contentType);
if (match && match.length === 2) {
req.headers['content-type'] = 'multipart/form-data; boundary="' + match[1] + '"';
}
next();
}); |
Summary: Fix for some firewall with ModSecurity rules for MULTIPART_STRICT_ERROR, namely MULTIPART_BOUNDARY_QUOTED. Closes facebook#10876 Reviewed By: javache Differential Revision: D4176229 Pulled By: ericvicenti fbshipit-source-id: 8db819bd3e9b23fa3c1802c48091bb4c44358381
|
For now @kfiroo 's fix works great though, thank you! |
When I attempt to upload file using the fetch + FormData, Android plays well and IOS always fails. After monitoring the http request, I found that IOS creates the http request as follows:
the boundary in the content-type is wrapped with delimiter "
and this is the android's:
This is probably cause by the code in _react-native/Libraries/Network/RCTNetworking.m_line 117
https://github.com/facebook/react-native/blob/5723915eaacfd3d8a8a7165c550f1fb9316c15ad/Libraries/Network/RCTNetworking.m
Another little problem is that ios does not add "content-length" for each part.
The text was updated successfully, but these errors were encountered: