Packages
mist
0.9.1
6.0.3
6.0.2
6.0.1
6.0.0
5.0.4
5.0.3
5.0.2
5.0.1
5.0.0
5.0.0-rc1
4.0.7
4.0.6
4.0.5
4.0.4
4.0.3
4.0.2
4.0.1
4.0.0
3.0.0
2.0.0
1.2.0
1.1.0
1.0.0
1.0.0-rc3
1.0.0-rc2
1.0.0-rc1
0.17.0
0.15.0
0.14.3
0.14.2
0.14.1
0.14.0
0.13.2
0.13.1
0.13.0
0.12.0
0.11.0
0.10.0
0.9.4
0.9.3
0.9.2
0.9.1
0.9.0
0.8.3
0.8.2
0.8.1
0.8.0
0.7.1
0.7.0
0.6.1
0.6.0
0.5.2
0.5.1
0.5.0
0.4.5
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.3
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.3
a misty Gleam web server
Current section
Files
Jump to
Current section
Files
src/http_ffi.erl
-module(http_ffi).
-export([binary_match/2, decode_packet/3, string_to_int/2]).
decode_packet(Type, Packet, Opts) ->
case erlang:decode_packet(Type, Packet, Opts) of
{ok, http_eoh, Rest} -> {ok, {end_of_headers, Rest}};
{ok, Binary, Rest} -> {ok, {binary_data, Binary, Rest}};
{more, Length} when Length =:= undefined -> {ok, {more_data, none}};
{more, Length} -> {ok, {more_data, {some, Length}}};
{error, Reason} -> {error, Reason}
end.
binary_match(Source, Pattern) ->
case binary:match(Source, Pattern) of
{Before, After} -> {ok, {Before, After}};
nomatch -> {error, nil}
end.
string_to_int(String, Base) ->
try {ok, erlang:list_to_integer(String, Base)}
catch
throw:badarg -> {error, nil}
end.