-
Notifications
You must be signed in to change notification settings - Fork 382
Null request payload/body values not handled properly #75
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
Comments
This behavior is intentional. It's generally the case in Dart that |
In that case, I feel like we could benefit from a better error message. Maybe something like this? http-0.11.3+9/lib/src/utils.dart String mapToQuery(Map<String, String> map, {Encoding encoding}) {
+ if (map.values.any((v) => (v == null))) { // -- null values found
+ throw new ArgumentError(map, "map", "NULL values not supported in querystring");
+ }
+
var pairs = <List<String>>[];
map.forEach((key, value) =>
pairs.add([Uri.encodeQueryComponent(key, encoding: encoding),
Uri.encodeQueryComponent(value, encoding: encoding)]));
return pairs.map((pair) => "${pair[0]}=${pair[1]}").join("&");
} |
For the same reason, we generally don't include explicit null checks in places where null isn't expected—otherwise we'd have them all over the place. |
Hi, so if I need to update a record on the server and set the value of one of the fields to be null, how can I accomplish this? |
It appears that
http/src/utils.dart
'smapToQuery()
method doesn't properly handle objects with null values causing unhandled exceptions:Repro code:
Suggested fix:
http-0.11.3+9/lib/src/utils.dart
Alternative fix:
http-0.11.3+9/lib/src/utils.dart
The text was updated successfully, but these errors were encountered: