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/ranch/1.7/guide/parsers/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/en/ranch/1.7/guide/parsers') diff --git a/docs/en/ranch/1.7/guide/parsers/index.html b/docs/en/ranch/1.7/guide/parsers/index.html index 0eb94a03..bb2f8e0e 100644 --- a/docs/en/ranch/1.7/guide/parsers/index.html +++ b/docs/en/ranch/1.7/guide/parsers/index.html @@ -76,7 +76,7 @@

Text protocols are generally line based. This means that we can't do anything with them until we receive the full line.

A simple way to get a full line is to use binary:split/2,3.

Using binary:split/2 to get a line of input
-
@@ -90,7 +90,7 @@ http://www.gnu.org/software/src-highlite -->

In the above example, we can have two results. Either there was a line break in the buffer and we get it split into two parts, the line and the rest of the buffer; or there was no line break in the buffer and we need to get more data from the socket.

Next, we need to parse the line. The simplest way is to again split, here on space. The difference is that we want to split on all spaces character, as we want to tokenize the whole string.

Using binary:split/3 to split text
-
@@ -111,7 +111,7 @@ http://www.gnu.org/software/src-highlite -->

Sometimes the size of the frame includes the first four bytes, sometimes not. Other times this size is encoded over two bytes. And even other times little-endian is used instead of big-endian.

The general idea stays the same though.

Using binary pattern matching to split frames
-
-- cgit v1.2.3