Branch
Hash :
ba62ee09
Author :
Thomas de Grivel
Date :
2025-09-11T23:02:18
fix test http
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
require HTTP
HTTP
require Socket
Socket
require Socket.Buf
Socket.Buf
require HTTP.Request
HTTP.Request
require HTTP.Response
HTTP.Response
(server = Socket.listen("localhost", "57000")) ; void
void
(client = Socket.Buf.connect("localhost", "57000")) ; void
void
(server_client = Socket.Buf.accept(server)) ; void
void
client_req = %HTTP.Request{method: GET}
%HTTP.Request{method: GET,
body: ?,
url: "/",
protocol: "HTTP/1.1",
client_addr: "",
headers: [],
cookies: [],
params: %{}}
HTTP.Request.buf_write(client_req, client.buf_rw.w)
(Sw) 18
req = HTTP.Request.buf_parse(server_client.buf_rw.r)
%HTTP.Request{method: GET,
body: void,
url: "/",
protocol: "HTTP/1.1",
client_addr: "",
headers: [],
cookies: [],
params: %{}}
puts(req)
%HTTP.Request{method: GET,
body: void,
url: "/",
protocol: "HTTP/1.1",
client_addr: "",
headers: [],
cookies: [],
params: %{}}
(Sw) 225
res = HTTP.Response.buf_write(%HTTP.Response{body: "Hello !"}, server_client.buf_rw.w, true)
(Sw) 70
client_response = HTTP.Response.buf_parse(client.buf_rw.r, true)
%HTTP.Response{protocol: "HTTP/1.1",
code: (U16) 200,
message: "OK",
headers: [{"Content-Type", "text/html"},
{"Content-Length", "7"}],
body: "Hello !"}
puts(client_response)
%HTTP.Response{protocol: "HTTP/1.1",
code: (U16) 200,
message: "OK",
headers: [{"Content-Type", "text/html"},
{"Content-Length", "7"}],
body: "Hello !"}
(Sw) 238
Socket.Buf.close(server_client)
void
Socket.Buf.close(client)
void
Socket.close(server)
void