contentType property

  1. @override
MediaType? contentType
inherited

Content-type of this request. Set automatically based on the body type and the encoding.

Implementation

@override
MediaType? get contentType {
  if (_contentType == null) {
    _contentType = defaultContentType;
    if (_contentType != null) {
      _contentType!.change(parameters: {'charset': encoding.name});
    }
  }
  return _contentType;
}
  1. @override
void contentType=(MediaType? contentType)
inherited

Manually set the content-type for this request.

NOTE: By default, the content-type will be set automatically based on the request type and the encoding. Once you set the content-type manually, we assume you are intentionally overriding this behavior and the content-type will no longer be updated when encoding changes.

Implementation

@override
set contentType(MediaType? contentType) {
  verifyUnsent();
  _wasContentTypeSetManually = true;
  updateContentType(contentType);
}