From 48f39402181d959cad88cb3f460210c007169f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 12 May 2021 11:13:47 +0200 Subject: Cowboy 2.9.0 --- .../2.9/manual/cowboy_req.stream_body/index.html | 210 +++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 docs/en/cowboy/2.9/manual/cowboy_req.stream_body/index.html (limited to 'docs/en/cowboy/2.9/manual/cowboy_req.stream_body/index.html') diff --git a/docs/en/cowboy/2.9/manual/cowboy_req.stream_body/index.html b/docs/en/cowboy/2.9/manual/cowboy_req.stream_body/index.html new file mode 100644 index 00000000..eaa80555 --- /dev/null +++ b/docs/en/cowboy/2.9/manual/cowboy_req.stream_body/index.html @@ -0,0 +1,210 @@ + + + + + + + + + + Nine Nines: cowboy_req:stream_body(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

cowboy_req:stream_body(3)

+ +

Name

+

cowboy_req:stream_body - Stream the response body

+

Description

+
+
stream_body(Data, IsFin, Req :: cowboy_req:req()) -> ok
+
+Data  :: cowboy_req:resp_body()
+IsFin :: fin | nofin
+
+

Stream the response body.

+

This function may be called as many times as needed after initiating a response using the cowboy_req:stream_reply(3) function.

+

The second argument indicates if this call is the final call. Use the nofin value until you know no more data will be sent. The final call should use fin (possibly with an empty data value) or be a call to the cowboy_req:stream_trailers(3) function.

+

Note that not using fin for the final call is not an error; Cowboy will take care of it when the request handler terminates if needed. Depending on the resource it may however be more efficient to do it as early as possible.

+

You do not need to handle HEAD requests specifically as Cowboy will ensure no data is sent when you call this function.

+

Arguments

+
Data
+

The data to be sent.

+
+
IsFin
+

A flag indicating whether this is the final piece of data to be sent.

+
+
Req
+

The Req object.

+
+
+

Return value

+

The atom ok is always returned. It can be safely ignored.

+

Changelog

+
  • 2.6: The Data argument can now be a sendfile tuple. +
  • +
  • 2.0: Function introduced. Replaces chunk/2. +
  • +
+

Examples

+
Stream the response body
+
+
Req = cowboy_req:stream_reply(200, #{
+    <<"content-type">> => <<"text/plain">>
+}, Req0),
+cowboy_req:stream_body(<<"Hello\n">>, nofin, Req),
+timer:sleep(1000),
+cowboy_req:stream_body(<<"World!\n">>, fin, Req).
+
+

See also

+

cowboy_req(3), cowboy_req:stream_reply(3), cowboy_req:stream_events(3), cowboy_req:stream_trailers(3)

+ + + + + + +
+ +
+ + +

+ Cowboy + 2.9 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +

Like my work? Donate!

+

Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:

+
+ + + + + + + + + +

Recurring payment options are also available via GitHub Sponsors. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.

+ + + +
+
+
+
+ + + + + + + + + -- cgit v1.2.3