Edit

kc3-lang/kc3/test/http/07_client_server.out.expected

Branch :

  • test/http/07_client_server.out.expected
  • 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", "57002")) ; void
    void
    (client = Socket.Buf.connect("localhost", "57002")) ; void
    void
    (server_client = Socket.Buf.accept(server)) ; void
    void
    client_req = %HTTP.Request{method: GET}
    %HTTP.Request{time: %Time{},
                  method: GET,
                  url: "/",
                  body: ?,
                  protocol: "HTTP/1.1",
                  client_addr: "",
                  headers: [],
                  cookies: [],
                  params: %{},
                  log_msg: ""}
    HTTP.Request.buf_write(client_req, client.buf_rw.w)
    (Sw) 37
    req = Struct.put(HTTP.Request.buf_parse(server_client.buf_rw.r), :time, %Time{})
    %HTTP.Request{time: %Time{},
                  method: GET,
                  url: "/",
                  body: void,
                  protocol: "HTTP/1.1",
                  client_addr: "",
                  headers: [{"Content-Length", (Uw) 0}],
                  cookies: [],
                  params: %{},
                  log_msg: ""}
    puts(req)
    %HTTP.Request{time: %Time{},
                  method: GET,
                  url: "/",
                  body: void,
                  protocol: "HTTP/1.1",
                  client_addr: "",
                  headers: [{"Content-Length", (Uw) 0}],
                  cookies: [],
                  params: %{},
                  log_msg: ""}
    (Sw) 307
    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