6.53. kink/http/REQ_CONTENT¶
6.53.1. type req_content¶
`req_content` is an abstract type of an HTTP request content.
A value is a `req_content` if and only if it implements the following methods.
6.53.1.1. Content.input¶
`input` method returns a new `input` which produces bytes of the HTTP request content.
`input` is called every time the request is retried, or redirected.
6.53.1.2. Content.have_media_type?¶
`have_media_type?` returns whether `Content` has a `media_type`.
6.53.1.3. Content.media_type¶
`media_type` returns the `media_type` of `Content`. If `Content` has no `media_type`, the result is unspecified.
The `media_type` value is used for Content-Type header of the request, when the header value is not explicitly specified.
Precondition
`Content.have_media_type?` must be true.
6.53.1.4. Content.have_bin?¶
`have_bin?` returns whether `Content` has a fixed `bin`.
6.53.1.5. Content.bin¶
`bin` returns the fixed `bin` of `Content`. If `Content` has no fixed `bin`, the result is unspecified.
Precondition
`Content.have_bin?` must be true.
6.53.2. REQ_CONTENT.from_bin(Bin ...[$config={}])¶
`from_bin` makes a `req_content` of a fixed `Bin`.
Config method:
• C.media_type(Media_type)
If C.media_type is called, `Media_type` is used as the media_type of the result `req_content`.
Preconditions
`Bin` must be a `bin`.
`Media_type` must be a `media_type`.
6.53.3. REQ_CONTENT.from_input($make_input ...[$config={}])¶
`from_input` returns a `req_content` which produces an `input` made by $make_input.
Config method:
• C.media_type(Media_type)
If C.media_type is called, `Media_type` is used as the media_type of the result `req_content`.
Preconditions
$make_input must be a thunk which returns an `input`.
`Media_type` must be a `media_type`.
6.53.4. REQ_CONTENT.from_output($generator ...[$config={}])¶
`from_output` returns a `req_content` which produces an `input` whose bytes are written to an `output` within invocation of $generator.
Config method:
• C.media_type(Media_type)
If C.media_type is called, `Media_type` is used as the media_type of the result `req_content`.
The input is made by GENERATOR_INPUT.new.
Preconditions
$generator must be a function which takes an `output`.
6.53.5. REQ_CONTENT.is?(Val)¶
`is?` returns whether `Val` is a `req_content`.
6.53.6. REQ_CONTENT.empty¶
`empty` returns a `req_content` of an empty `bin`, with no `media_type`.