Hash :
58a36064
Author :
Thomas de Grivel
Date :
2024-09-10T18:41:53
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
quote server = Socket.listen("localhost", "57000")
server = Socket.listen("localhost", "57000")
quote client = Socket.Buf.connect("localhost", "57000")
client = Socket.Buf.connect("localhost", "57000")
quote server_client = Socket.accept(server)
server_client = Socket.Buf.accept(server)
quote Buf.write_str(client.buf_rw.w, "GET / HTTP/1.0\r\n\r\n")
Buf.write_str(client.buf_rw.w, "GET / HTTP/1.0\r\n\r\n")
quote req = HTTP.Request.buf_parse(server_client.buf_rw.r)
req = HTTP.Request.buf_parse(server_client.buf_rw.r)
quote response = %HTTP.Response{body: "Hello, KC3 HTTP test server !"}
response = %HTTP.Response{body: "Hello, KC3 HTTP test server !"}
quote HTTP.Response.buf_write(response, client.buf_rw.w, true)
HTTP.Response.buf_write(response, client.buf_rw.w, true)
quote client_req = %HTTP.Request{method: :get,
url: "/",
protocol: "HTTP/1.1",
headers: []}
client_req = %HTTP.Request{method: :get,
url: "/",
protocol: "HTTP/1.1",
headers: []}
quote HTTP.Request.buf_write(client_req, client.buf_rw.w)
HTTP.Request.buf_write(client_req, client.buf_rw.w)
quote HTTP.Request.buf_parse(server_client.buf_rw.r)
HTTP.Request.buf_parse(server_client.buf_rw.r)
quote HTTP.Response.buf_write(response, client.buf_rw.w, true)
HTTP.Response.buf_write(response, client.buf_rw.w, true)
quote HTTP.Request.buf_parse(server_client.buf_rw.r)
HTTP.Request.buf_parse(server_client.buf_rw.r)
quote HTTP.Response.buf_write(response, client.buf_rw.w, true)
HTTP.Response.buf_write(response, client.buf_rw.w, true)
quote Socket.Buf.close(client)
Socket.Buf.close(client)
quote Socket.Buf.close(server_client)
Socket.Buf.close(server_client)
quote Socket.close(server)
Socket.close(server)