working get request, for http 1

This commit is contained in:
Ruben Shekspir 2019-02-23 10:30:39 +04:00
parent 84b04c2b37
commit 6686997ed2
2 changed files with 10 additions and 9 deletions

View file

@ -1,12 +1,14 @@
MODULE http; MODULE http;
IMPORT Internet, Out; IMPORT Internet, Out;
PROCEDURE get(host, port: ARRAY OF CHAR, VAR buff: ARRAY 1000 OF CHAR); VAR
buff: ARRAY 1000 OF CHAR;
PROCEDURE get(host, port: ARRAY OF CHAR; VAR buff: ARRAY OF CHAR);
VAR VAR
socket : Internet.Socket; socket : Internet.Socket;
connected: BOOLEAN; connectionFlag: BOOLEAN;
send: ARRAY 7 OF CHAR; send: ARRAY 7 OF CHAR;
BEGIN BEGIN
connected := Internet.Connect(host, port, socket); connectionFlag := Internet.Connect(host, port, socket);
send[0] := "G"; send[0] := "G";
send[1] := "E"; send[1] := "E";
send[2] := "T"; send[2] := "T";
@ -15,15 +17,13 @@ BEGIN
send[5] := " "; send[5] := " ";
(* Somewhy it's ignoring the last byte *) (* Somewhy it's ignoring the last byte *)
connected := Internet.Write(socket, send); connectionFlag := Internet.Write(socket, send);
connected := Internet.Read(socket, buff); connectionFlag := Internet.Read(socket, buff);
Internet.Disconnect(socket); Internet.Disconnect(socket);
END get; END get;
VAR
buff: ARRAY 1000 OF CHAR
BEGIN BEGIN
get("google.am", "80", buff); get("voto.am", "80", buff);
Out.String(buff); Out.String(buff);
Out.Ln; Out.Ln;
END http. END http.

View file

@ -12,6 +12,7 @@ clean:
rm *.c rm *.c
rm *.o rm *.o
rm *.sym rm *.sym
rm http
test: http test: http
./http ./http