小编Kei*_*mel的帖子

使用 tcpserver 服务 http 请求

我正在尝试使用 ucspi-tcp 中的 tcpserver 来启动一个返回简单网页的脚本。我的脚本(hello.lua)如下:

#!/usr/bin/env lua
print([[HTTP/1.1 200 OK
Content-Type: text/html
<html>
<head>
<title>My title</title>
</head>
<body>
<h1>Hello in big font</h1>
</body>
</html>]])

我启动它 tcpserver -v -rh 0 9000 /path/to/hello.lua

当我使用时tcpcat myserver 9000,我得到了预期的回报:
HTTP/1.1 200 OK
Content-Type: text/html
<html>
<head>
<title>My title</title>
</head>
<body>
<h1> Hello in big font</h1>
</body>
</html>

但是,当我尝试使用网络浏览器并指向 时,即使 tcpserver 日志记录显示事务http:\\myserver:9000,我Error 101 (net::ERR_CONNECTION_RESET): Unknown error也会收到浏览器错误(在 Chrome 中):
tcpserver: status 1/40
tcpserver: pid 21672 from <ip address of browser>
tcpserver: …

http

4
推荐指数
1
解决办法
1075
查看次数

标签 统计

http ×1