You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to be able to set bodyFields with a map that has multiple values for a single key, so map would be Map<String, Object> where Object would be either a String or List at runtime. Here is an example map: {q: :, start: 0, rows: 0, facet: true, stats: true, stats.field: [{!countDistinct=true }vin, {!countDistinct=true }veh_year]}
Here is sample code of changes I would like, this is example code only, implementation could be a lot better:
//http 0.11.3+9/lib/src/request.dart - change Map input from <String, String> to <String, Object>setbodyFields(Map<String, Object> fields) {
var contentType = _contentType;
if (contentType ==null) {
_contentType =newMediaType("application", "x-www-form-urlencoded");
} elseif (contentType.mimeType !="application/x-www-form-urlencoded") {
thrownewStateError('Cannot set the body fields of a Request with ''content-type "${contentType.mimeType}".');
}
this.body =mapToQuery(fields, encoding: encoding);
}
//http 0.11.3+9/lib/src/utils.dart - rewrite to put key in multiple times when value is a list./// Converts a [Map] from parameter names to values to a URL query string. /// /// mapToQuery({"foo": "bar", "baz": "bang"}); /// //=> "foo=bar&baz=bang"StringmapToQuery(Map<String, Object> map, {Encoding encoding}) {
String retStr ='';
String delimiter ='';
var keys = map.keys;
for (String key in keys) {
var value = map[key];
if (value isList) {
for (String subvalue in value) {
retStr +="${delimiter}${key}=${subvalue}";
delimiter='&';
}
}
else {
retStr +="${delimiter}${key}=${value}";
delimiter='&';
}
}
return retStr;
}
The text was updated successfully, but these errors were encountered:
I need to be able to set bodyFields with a map that has multiple values for a single key, so map would be Map<String, Object> where Object would be either a String or List at runtime. Here is an example map: {q: :, start: 0, rows: 0, facet: true, stats: true, stats.field: [{!countDistinct=true }vin, {!countDistinct=true }veh_year]}
Here is sample code of changes I would like, this is example code only, implementation could be a lot better:
The text was updated successfully, but these errors were encountered: