From 8459bebceb9533948193774371cbd9fd571b78ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 16 Oct 2019 09:48:31 +0200 Subject: Cowboy 2.7.0 --- docs/en/gun/1.0/guide/http/index.html | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'docs/en/gun/1.0/guide/http') diff --git a/docs/en/gun/1.0/guide/http/index.html b/docs/en/gun/1.0/guide/http/index.html index 0fd7edea..fb4105df 100644 --- a/docs/en/gun/1.0/guide/http/index.html +++ b/docs/en/gun/1.0/guide/http/index.html @@ -69,7 +69,7 @@

Streams can be canceled at any time. This will stop any further messages from being sent to the owner process. Depending on its capabilities, the server will also be instructed to cancel the request.

Canceling a stream may result in Gun dropping the connection temporarily, to avoid uploading or downloading data that will not be used.

Cancelling a stream
-
@@ -83,14 +83,14 @@ http://www.gnu.org/software/src-highlite -->

GET and HEAD

Use gun:get/2,3,4 to request a resource.

GET "/organizations/ninenines"
-
StreamRef = gun:get(ConnPid, "/organizations/ninenines").
GET "/organizations/ninenines" with custom headers
-
@@ -102,14 +102,14 @@ http://www.gnu.org/software/src-highlite -->

Note that the list of headers has the field name as a binary. The field value is iodata, which is either a binary or an iolist.

Use gun:head/2,3,4 if you don't need the response body.

HEAD "/organizations/ninenines"
-
StreamRef = gun:head(ConnPid, "/organizations/ninenines").
HEAD "/organizations/ninenines" with custom headers
-
@@ -128,7 +128,7 @@ http://www.gnu.org/software/src-highlite -->

The gun:post/4,5, gun:put/4,5 and gun:patch/4,5 functions take a body as their fourth argument. These functions do not require any body-specific header to be set, although it is always recommended to set the content-type header. Gun will set the other headers automatically.

In this and the following examples in this section, gun:post can be replaced by gun:put or gun:patch for performing a PUT or PATCH request, respectively.

POST "/organizations/ninenines"
-
@@ -140,7 +140,7 @@ http://www.gnu.org/software/src-highlite -->

The gun:post/3, gun:put/3 and gun:patch/3 functions do not take a body in their arguments. If a body is to be provided later on, using the gun:data/4 function, then the request headers must indicate this. This can be done by setting the content-length or content-type request headers. If these headers are not set then Gun will assume the request has no body.

It is recommended to send the content-length header if you know it in advance, although this is not required. If it is not set, HTTP/1.1 will use the chunked transfer-encoding, and HTTP/2 will continue normally as it is chunked by design.

POST "/organizations/ninenines" with delayed body
-
@@ -153,7 +153,7 @@ http://www.gnu.org/software/src-highlite -->

The atom fin indicates this is the last chunk of data to be sent. You can call the gun:data/4 function as many times as needed until you have sent the entire body. The last call must use fin and all the previous calls must use nofin. The last chunk may be empty.

Streaming the request body
-
@@ -174,14 +174,14 @@ http://www.gnu.org/software/src-highlite -->

DELETE

Use gun:delete/2,3,4 to delete a resource.

DELETE "/organizations/ninenines"
-
StreamRef = gun:delete(ConnPid, "/organizations/ninenines").
DELETE "/organizations/ninenines" with custom headers
-
@@ -192,14 +192,14 @@ http://www.gnu.org/software/src-highlite -->

OPTIONS

Use gun:options/2,3 to request information about a resource.

OPTIONS "/organizations/ninenines"
-
StreamRef = gun:options(ConnPid, "/organizations/ninenines").
OPTIONS "/organizations/ninenines" with custom headers
-
@@ -209,7 +209,7 @@ http://www.gnu.org/software/src-highlite -->

You can also use this function to request information about the server itself.

OPTIONS "*"
-
@@ -218,7 +218,7 @@ http://www.gnu.org/software/src-highlite -->

Requests with an arbitrary method

The gun:request/4,5,6 function can be used to send requests with a configurable method name. It is mostly useful when you need a method that Gun does not understand natively.

Example of a TRACE request
-
@@ -232,7 +232,7 @@ http://www.gnu.org/software/src-highlite -->

When using HTTP/2 this value is sent with the frame and simply passed on in the message. When using HTTP/1.1 however Gun must guess whether data will follow by looking at the response headers.

You can receive messages directly, or you can use the await functions to let Gun receive them for you.

Receiving a response using receive
-
@@ -270,7 +270,7 @@ http://www.gnu.org/software/src-highlite -->

When calling gun:await/2,3 and not passing a monitor reference, one is automatically created for you for the duration of the call.

The gun:await_body/2,3,4 works similarly, but returns the body received. Both functions can be combined to receive the response and its body sequentially.

Receiving a response using await
-
@@ -288,7 +288,7 @@ http://www.gnu.org/software/src-highlite -->

You can safely choose to ignore gun_push messages, or you can handle them. If you do, you can either receive the messages directly or use await functions.

The gun_push message contains both the new stream reference and the stream reference of the original request.

Receiving a pushed response using receive
-
@@ -300,7 +300,7 @@ http://www.gnu.org/software/src-highlite -->

If you use the gun:await/2,3,4 function, however, Gun will use the original reference to identify the message but will return a tuple that doesn't contain it.

Receiving a pushed response using await
-
@@ -311,14 +311,14 @@ http://www.gnu.org/software/src-highlite -->

Flushing unwanted messages

Gun provides the function gun:flush/1 to quickly get rid of unwanted messages sitting in the process mailbox. You can use it to get rid of all messages related to a connection, or just the messages related to a stream.

Flush all messages from a Gun connection
-
gun:flush(ConnPid).
Flush all messages from a specific stream
-
@@ -327,7 +327,7 @@ http://www.gnu.org/software/src-highlite -->

Redirecting responses to a different process

Gun allows you to specify which process will handle responses to a request via the reply_to request option.

GET "/organizations/ninenines" to a different process
-
-- cgit v1.2.3