Skip to content

Commit

Permalink
use read_line_to_chars/3
Browse files Browse the repository at this point in the history
This is contingent on mthom/scryer-prolog#590.
  • Loading branch information
triska committed Jun 13, 2020
1 parent 26db85e commit e60a2fd
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions server.pl
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
accept_loop(Socket).

request_response(Stream) :-
( read_line(Stream, Chars) ->
( read_line_to_chars(Stream, Chars, []),
format("got line: ~w~n", [Chars]),
append("GET /", Rest, Chars),
append(Path, [' '|_], Rest),
append(Path, [' '|_], Rest) ->
format("request is for ~q~n", [Path]),
( dif(Path, ""),
path_file(Path, FileChars),
Expand Down Expand Up @@ -105,16 +105,6 @@
format_("~d", [L]),
"\r\n\r\n".

read_line(Stream, Chars) :-
get_byte(Stream, Byte),
Byte >= 0,
char_code(Char, Byte),
( member(Char, "\r\n") ->
Chars = []
; Chars = [Char|Rest],
read_line(Stream, Rest)
).

%?- phrase_from_file(list(Cs), 'server.pl', [type(binary)]).
%@ Cs = "/* - - - - - - - - ..."

Expand Down

0 comments on commit e60a2fd

Please sign in to comment.