简体   繁体   English

是否忽略了HTTP服务器头响应?

[英]is HTTP server header response ignored?

I make very simple HTTP server in Java. 我用Java制作了非常简单的HTTP服务器。 The response sent to the browser is 发送到浏览器的响应是

HTTP 1.1 200 OK
Server: OneFile 1.0
Content-Type: text/html; charset=utf-8
Content-Length: 202
Transfer-Encoding: chunked

<HTML><HEAD><TITLE>My website</TITLE></HEAD>
<BODY><H1>Document </H1>
</BODY></HTML>

mozilla firefox displays it as text/plain although it should be text/html Why? mozilla firefox将其显示为text / plain虽然它应该是text / html为什么?
I suspect the Setup info is ignored...is it any difference for browser if I make connection on port 8080? 我怀疑安装信息被忽略了...如果我在端口8080上建立连接,浏览器是否有任何区别? Thanks for any help 谢谢你的帮助

The browser will honor your headers. 浏览器将尊重您的标题。 Unfortunately, your response is malformed for several reasons: 不幸的是,由于以下几个原因,您的回复出错:

  • the response should start HTTP/1.1 , not HTTP 1.1 响应应该启动HTTP/1.1 ,而不是HTTP 1.1
  • you specify Transfer-Encoding: chunked , but your response does not follow the chunked format. 您指定Transfer-Encoding: chunked ,但您的响应不遵循chunked格式。

It appears that Firefox, quite sensibly, refuses to interpret such malformed response and just shows it unchanged. 似乎Firefox非常明智地拒绝解释这种格式错误的反应,只是表明它没有变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM