PuTTY 在测试我的服务器时返回混乱的 HTML
我正在编写一个小型网络服务器来为项目生成网络界面。我使用的环境是LabVIEW,因为它是我最熟悉的。
问题是,当我用PuTTY发送GET / HTTP/1.1
时,它返回
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
<html>
Content-Length: 52
<head>
foo
</head>
<body>
bar
</body>
</html>
LabVIEW,说发送出去的字符串是:
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 52
<html>
<head>
foo
</head>
<body>
bar
</body>
</html>
当直接在Web浏览器中打开HTML文件时,它可以正确打开。当从服务器程序请求它时,页面没有完成加载,并且从不显示任何内容。我相当确定 HTML 是有效的。
我怎样才能更好地调试这个?我是否缺少 PuTTY 中的设置?我需要与 National Instruments 联系吗?
I'm writing a small web-server to generate a web interface for a project. The environment I'm using is LabVIEW, because it's what I'm most familiar with.
The problem is that when I send it GET / HTTP/1.1
with PuTTY, it returns
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
<html>
Content-Length: 52
<head>
foo
</head>
<body>
bar
</body>
</html>
LabVIEW says the string being sent out is:
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 52
<html>
<head>
foo
</head>
<body>
bar
</body>
</html>
When opening the HTML file in the web browser directly, it opens properly. When requesting it from the server program, the page doesn't finish loading, and never displays anything. I'm fairly sure the HTML is valid.
How can I debug this better? Am I missing a setting in PuTTY? Do I need to talk to National Instruments?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,请注意这不是有效的 HTTP,因为最后一个标头后面应该有一个空行;这可能是在浏览器中查看的问题。
其次,我敢打赌您不会一次打印所有文本,而是通过与 HTML 分开的某个通道打印标题,这样它们就可以交错排列。确保您使用同一管道发送所有数据。
First, note that this isn't valid HTTP as there's supposed to be a blank line after the last header; that might be the problem with viewing in a browser.
Secondly, I bet you're not printing all the text at once, but rather printing the headers through some channel separate from the HTML, so they can get interleaved. Make sure you're using the same pipe to send all the data.
您可以尝试从命令行使用 Windows telnet 进行连接。可能会给你另一个线索。
另外,尝试在 PuTTY 中打开日志记录并使用十六进制编辑器查看日志文件。也许中间有一些“奇怪”的字符会混淆输出 - 你永远不知道。
并且:检查您是否使用“Raw”连接类型而不是“Telnet”连接 PuTTY。
You could try to connect using windows telnet from the command line. Might possibly give you another clue.
Also, try to turn on logging in PuTTY and have a look at the logfile with a HEX-Editor. Maybe there are some "weird" characters in between which confuse the output - you never know.
And: Check that you are connecting with PuTTY using the "Raw" connection type and not "Telnet".