thttpd仅支持静态页面的HTTP 1.1吗? 对CGI生成页面的HTTP请求似乎只响应HTTP 1.0。
=========================
$ curl -i http://<ip address>index.html HTTP/1.1 200 OK Server: thttpd/2.25b 29dec2003 Content-Type: text/html; charset=iso-8859-1 Date: Tue, 04 Aug 2009 07:00:52 GMT Last-Modified: Tue, 04 Aug 2009 06:58:04 GMT Accept-Ranges: bytes Connection: close Content-Length: 74 <html> <head><title>blah</title></ head> <body>Hello There!</body> </html> $ curl -i http://<ip address>/cgi-bin/hello HTTP/1.0 200 OK Content-type: text/html Hello there!
=========================
thttpd CGI甚至不能响应HTTP HEAD请求。
$ curl --head http://<ip address>/cgi-bin/hello HTTP/1.1 501 Not Implemented Server: thttpd/2.25b 29dec2003 Content-Type: text/html; charset=iso-8859-1 Date: Tue, 04 Aug 2009 07:02:36 GMT Last-Modified: Tue, 04 Aug 2009 07:02:36 GMT Accept-Ranges: bytes Connection: close Cache-Control: no-cache,no-store
=========================
有没有办法在CGI请求上启用HTTP 1.1? 顺便说一句,这是使用thttpd ver.2.25b。
谢谢,Kenneth
如您所知,thttpd与dhttpd不同,支持CGI,但手册页并未引用文档中请求所支持的HTTP级别。 从thttpd手册页:
CGI thttpd supports the CGI 1.1 spec. In order for a CGI program to be run, its name must match the pattern specified either at compile time or on the command line with the -c flag. This is a simple shell-style filename pattern. You can use * to match any string not including a slash, or ** to match any string including slashes, or ? to match any single character. You can also use multiple such patterns separated by |. The patterns get checked against the filename part of the incoming URL. Don't forget to quote any wildcard characters so that the shell doesn't mess with them. Restricting CGI programs to a single directory lets the site adminis‐ trator review them for security holes, and is strongly recommended. If there are individual users that you trust, you can enable their direc‐ tories too. If no CGI pattern is specified, neither here nor at compile time, then CGI programs cannot be run at all. If you want to disable CGI as a security measure, that's how you do it, just comment out the patterns in the config file and don't run with the -c flag. Note: the current working directory when a CGI program gets run is the directory that the CGI program lives in. This isn't in the CGI 1.1 spec, but it's what most other HTTP servers do. Relevant config.h options: CGI_PATTERN, CGI_TIMELIMIT, CGI_NICE, CGI_PATH, CGI_LD_LIBRARY_PATH, CGIBINDIR.
关于HTTP 1.1支持的具体问题,我想在thttpd支持论坛上提出的问题可能是最好的方法,而不是阅读代码。 我不会对HTTP 1.0感到惊讶,因为它保存了服务器必须存储页面的部分,直到整个页面可用,以便在HTTP 1.1标头中正确填写字节数。
当然,在cgi_interpose_output( httpd_conn* hc, int rfd )的例程cgi_interpose_output( httpd_conn* hc, int rfd )中,
(void) my_snprintf( buf, sizeof(buf), "HTTP/1.0 %d %s\015\012", status, title );
似乎支持这种观点,但我希望你可能比我更熟悉代码,邮件列表上的人会详细了解它,并可能更明确。