Body.Full #
A body backed by a fixed ByteArray held in a Mutex.
The byte array is consumed at most once: the first call to recv atomically takes the data
and returns it as a single chunk; subsequent calls return none (end-of-stream).
Closing the body discards any unconsumed data.
Creates a Full body from a ByteArray.
Equations
- Std.Http.Body.Full.ofByteArray data = do let state ← liftM (Std.Mutex.new (some data)) pure { state := state }
Instances For
Receives the body data. Returns the full byte array on the first call as a single chunk,
then none on all subsequent calls.
Equations
Instances For
Closes the body, discarding any unconsumed data.
Equations
- full.close = (Std.Http.Body.Full.state✝ full).atomically (set none)
Instances For
Returns true when the data has been consumed or the body has been closed.
Equations
- full.isClosed = (Std.Http.Body.Full.state✝ full).atomically do let __do_lift ← get pure __do_lift.isNone
Instances For
Returns the known size of the remaining data.
Returns some (.fixed n) with the current byte count, or some (.fixed 0) if the body has
already been consumed or closed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Selector that immediately resolves to the remaining chunk (or EOF).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
Equations
- Std.Http.Body.instCoeResponseFullAny = { coe := fun (f : Std.Http.Response Std.Http.Body.Full) => { line := f.line, body := Std.Http.Body.Any.ofBody f.body, extensions := f.extensions } }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Builds a request body from raw bytes without setting any headers.
Use bytes instead if you want Content-Type: application/octet-stream set automatically.
Equations
- builder.fromBytes content = do let __do_lift ← Std.Http.Body.Full.ofByteArray content pure (builder.body __do_lift)
Instances For
Builds a request with a binary body.
Sets Content-Type: application/octet-stream.
Use fromBytes instead if you need to set a different Content-Type or none at all.
Equations
- builder.bytes content = (builder.header Std.Http.Header.Name.contentType (Std.Http.Header.Value.ofString! "application/octet-stream")).fromBytes content
Instances For
Builds a request with a text body.
Sets Content-Type: text/plain; charset=utf-8.
Equations
- builder.text content = (builder.header Std.Http.Header.Name.contentType (Std.Http.Header.Value.ofString! "text/plain; charset=utf-8")).fromBytes content.toUTF8
Instances For
Builds a request with a JSON body.
Sets Content-Type: application/json.
Equations
- builder.json content = (builder.header Std.Http.Header.Name.contentType (Std.Http.Header.Value.ofString! "application/json")).fromBytes content.toUTF8
Instances For
Builds a request with an HTML body.
Sets Content-Type: text/html; charset=utf-8.
Equations
- builder.html content = (builder.header Std.Http.Header.Name.contentType (Std.Http.Header.Value.ofString! "text/html; charset=utf-8")).fromBytes content.toUTF8
Instances For
Builds a response body from raw bytes without setting any headers.
Use bytes instead if you want Content-Type: application/octet-stream set automatically.
Equations
- builder.fromBytes content = do let __do_lift ← Std.Http.Body.Full.ofByteArray content pure (builder.body __do_lift)
Instances For
Builds a response with a binary body.
Sets Content-Type: application/octet-stream.
Use fromBytes instead if you need to set a different Content-Type or none at all.
Equations
- builder.bytes content = (builder.header Std.Http.Header.Name.contentType (Std.Http.Header.Value.ofString! "application/octet-stream")).fromBytes content
Instances For
Builds a response with a text body.
Sets Content-Type: text/plain; charset=utf-8.
Equations
- builder.text content = (builder.header Std.Http.Header.Name.contentType (Std.Http.Header.Value.ofString! "text/plain; charset=utf-8")).fromBytes content.toUTF8
Instances For
Builds a response with a JSON body.
Sets Content-Type: application/json.
Equations
- builder.json content = (builder.header Std.Http.Header.Name.contentType (Std.Http.Header.Value.ofString! "application/json")).fromBytes content.toUTF8
Instances For
Builds a response with an HTML body.
Sets Content-Type: text/html; charset=utf-8.
Equations
- builder.html content = (builder.header Std.Http.Header.Name.contentType (Std.Http.Header.Value.ofString! "text/html; charset=utf-8")).fromBytes content.toUTF8