我做了一个套接字,它将接受端口上的任何获取/发布请求。
现在,基于uri,它会向repl输出不同的字符串。
/
只会说“你好”
/whatever
说“你好,随便”
但是现在我需要将响应发送到浏览器,这就是我所拥有的,但是我没有在浏览器中得到响应:
(def output (.getOutputStream accepted-socket))
(map (fn[char] (.write @output (int char)))
"HTTP/1.1 200 OK\nContent-Type: text/html\nContent-Length: 44\nConnection: close\r\n\r\n
<html><body><h1 Please work!/></body></html>")
user=> (import 'java.net.Socket)
java.net.Socket
user=> (def s (Socket. "localhost" 7777))
#'user/s
user=> (with-open [o (io/writer s)]
(.write o "hello, world"))
nil