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
A minor change to how field names are encoded #161
base: master
Are you sure you want to change the base?
Conversation
I recently needed to use an API that couldn't handle the field names being encoded with quotes. I added an optional parameter to FormData.append, that can remove the quotes. Others in a similar situation might find it useful and it can have no side effects on existing code as far as I can see.
Thanks for your interest in the package. Do you mind to elaborate on your use case? Seems like one-off from here, especially comparing with the number of changes. And I see more changes than just described change. PS. |
@@ -159,7 +159,7 @@ FormData.prototype._trackLength = function(header, value, options) { | |||
}; | |||
|
|||
// TODO: Use request's response mime-type | |||
FormData.prototype._multiPartHeader = function(field, value, options) { | |||
FormData.prototype._multiPartHeader = function(field, value, options,encodeFieldNamesWithoutQuotes) { |
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.
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.
I would recommend to move this parameter to the options, since it may be passed here anyway.
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.
+1, thanks
Hi Alex. Thanks for the quick response. Is it the standard that the field names have to be surrounded by quotes? i.e. |
} else if (value.hasOwnProperty('httpVersion')) { | ||
next(null, +value.headers['content-length']); | ||
|
||
// or request stream http://github.com/mikeal/request | ||
// or request stream http://github.com/mikeal/request |
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.
Do you mind to clean up unnecessary changes like this?
And add tests for the use case?
Thank you.
@phatmaus Thanks for the details. Could you put details on the server/environment in the comments block in the new test file (and mention it in the readme). I think it would help others to find solution faster than just introducing verbose flag. Thanks. |
Based on the RFC https://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1 |
@danielgindi correct. but |
@Igorbek of course! |
This is old, I think it was never implemented, but I ran into this same issue - a third-party api that cannot parse the quotes. |
I recently needed to use an API that couldn't handle the field names being
encoded with quotes. I added an optional parameter to FormData.append,
that can remove the quotes. Others in a similar situation might find it
useful and it can have no side effects on existing code as far as I can
see.