classafButter::Body
sys::Obj afButter::Body
Convenience methods for reading and writing content.
- buf
Buf? bufGets and sets the body content as a
Buf.- charset
Charset? charsetThe charset used to en / decode the string and json objects. If left as
nullthen it defaults to theContent-TypeHTTP Header, or UTF-8 if not set.charsetshould be set before the body content.- form
Gets and sets the body content as a URL encoded form (think forms on web pages).
Uri.encodeQuery()/Uri.decodeQuery()methods are used to convert objects to and from form values.When set, the
Content-Typeis set toapplication/x-www-form-urlencoded(if it's not been set already).Returns the empty map
Str:Str[:]if the body has not been set.- json
Str? jsonGets and sets the body content as a JSON string.
When set, the
Content-Typeis set toapplication/json(if it's not been set already).Returns
nullif the body has not been set.- jsonList
Obj?[]? jsonListGets and set the body content as a JSON list. Convenience for
(Obj?[]?) body.jsonObj.When set, the
Content-Typeis set toapplication/json(if it's not been set already).Returns
nullif the body has not been set.Note that JsonOutStream is used for the conversion. See the Json library should you need pretty printing or more control over conversion.
- jsonMap
Gets and set the body content as a JSON map. Convenience for
([Str:Obj?]?) body.jsonObj.When set, the
Content-Typeis set toapplication/json(if it's not been set already).Returns
nullif the body has not been set.Note that JsonOutStream is used for the conversion. See the Json library should you need pretty printing or more control over conversion.
- jsonObj
Obj? jsonObjGets and sets the body content as a JSON object.
JsonInStream/JsonOutStreamare used to convert objects to and from JSON strings.When set, the
Content-Typeis set toapplication/json(if it's not been set already).Returns
nullif the body has not been set.Note that JsonOutStream is used for the conversion. See the Json library should you need pretty printing or more control over conversion.
- size
Int size()Returns the size of the body in bytes. Shortcut for
buf?.size ?: 0.- str
Str? strGets and sets the body content as a string. The string is en / decoded using a charset found in the following precedence:
- any charset set via the
charsetfield - the charset defined in a
Content-TypeHTTP header - UTF-8
When set, the
Content-Typeis set totext/plain(if it's not been set already).Returns
nullif the body has not been set.- any charset set via the