The form-encoded fields in the body of the request as a map from field names to values. The form-encoded body is converted to and from bodyBytes using encoding (in the same way as body).
If the request doesn't have a Content-Type
header of
application/x-www-form-urlencoded
, reading this will throw a
StateError.
If the request has a Content-Type
header with a type other than
application/x-www-form-urlencoded
, setting this will throw a
StateError. Otherwise, the content type will be set to
application/x-www-form-urlencoded
.
This map should only be set, not modified in place.
Source
Map<String, String> get bodyFields { MediaType contentType = _contentType; if (contentType == null || contentType.mimeType != "application/x-www-form-urlencoded") { throw new StateError('Cannot access the body fields of a Request without ' 'content-type "application/x-www-form-urlencoded".'); } return Uri.splitQueryString(body, encoding: encoding); }
Source
set bodyFields(Map<String, String> fields) { MediaType contentType = _contentType; if (contentType == null) { _contentType = new MediaType("application", "x-www-form-urlencoded"); } else if (contentType.mimeType != "application/x-www-form-urlencoded") { throw new StateError('Cannot set the body fields of a Request with ' 'content-type "${contentType.mimeType}".'); } this.body = mapToQuery(fields, encoding: encoding); }