aboutsummaryrefslogtreecommitdiffstats
path: root/guide
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-08-29 15:58:38 +0200
committerLoïc Hoguin <[email protected]>2013-08-29 15:58:38 +0200
commit3a048dc90ba0e96a0f8fc777cb94f0b68f622bce (patch)
tree5a9732431fba4990aa5f9b47f3bcff341a2b3ea7 /guide
parentcc4d27be1b18f39d6dc57fee0ed99cab701b34d1 (diff)
downloadgun-3a048dc90ba0e96a0f8fc777cb94f0b68f622bce.tar.gz
gun-3a048dc90ba0e96a0f8fc777cb94f0b68f622bce.tar.bz2
gun-3a048dc90ba0e96a0f8fc777cb94f0b68f622bce.zip
The gun_response message now says if data will follow
Diffstat (limited to 'guide')
-rw-r--r--guide/http.md18
1 files changed, 12 insertions, 6 deletions
diff --git a/guide/http.md b/guide/http.md
index a44e95a..2b16f1a 100644
--- a/guide/http.md
+++ b/guide/http.md
@@ -150,11 +150,15 @@ process as a message. First a response message is sent, then
zero or more data messages. If something goes wrong, error
messages are sent instead.
-You can find out whether data will be sent by checking the
-presence of the content-type or content-length header and
-making sure the length isn't 0. If you already know a body is
-going to be sent you can skip this check, however do make
-sure you have a timeout just in case something goes wrong.
+The response message will inform you whether there will be
+data messages following. If it contains `fin` then no data
+will follow. If it contains `nofin` then one or more data
+messages will arrive.
+
+When using SPDY this value is sent along the frame and simply
+passed on in the message. When using HTTP however Gun must
+guess whether data will follow by looking at the headers
+as documented in the HTTP RFC.
``` erlang
StreamRef = gun:get(Pid, "/"),
@@ -162,7 +166,9 @@ receive
{'DOWN', Tag, _, _, Reason} ->
error_logger:error_msg("Oops!"),
exit(Reason);
- {gun_response, Pid, StreamRef, Status, Headers} ->
+ {gun_response, Pid, StreamRef, fin, Status, Headers} ->
+ no_data;
+ {gun_response, Pid, StreamRef, nofin, Status, Headers} ->
receive_data(Pid, StreamRef)
after 1000 ->
exit(timeout)