This article will introduce the HTTP/1.1 open unknown error of Express for your reference. The architecture is as follows: NodeJS + Express, using EJS as the template.
The error is as follows:
| The Code is as follows: |
Copy code |
HTTP/1.1 open unknown X-Powered-By: Express Content-Type: text/html; charset = UTF-8 Content-Length: 11874 Set-Cookie: connect. sid = x4iNL4p1zGLt5mhMphHtiDFh. Capacity % 2FY0; path =/; expires = Thu, 21 Jun 2012 06:54:36 GMT; httpOnly Connection: keep-alive |
When rendering some pages, Express will put the above text in front of the HTML document body, Some browsers (Chrome, IE) will ignore the text, it looks normal. Another browser (Opera) will continue to wait for the server to return, as the page has been rendered, but JavaScript is not executed, and it will remain in Loading until it times out, press the stop key to load the page. In other browsers (mainly Safari), the document is regarded as plain text and the source code is displayed ,. Maybe it is the reason why the Express user group is small. I have never been able to find the cause of this problem. After arduous debugging, I finally found the cause. The following are the culprit. Note that in row 192, I read the parameter "status" from the URL and passed it to the EJS template using the name "status" as the template parameter. In the EJS template, the tragedy occurs. Change to this mode: Avoid using <% = status %> In EJS, and use <% = docstatus %> instead. The problem is solved immediately. I am not quite clear about the mechanism of the error. I guess the status variable may have another function in the EJS parameters. I wish you an early solution to the HTTP/1.1 open unknown issue.