Index: [Article Count Order] [Thread]

Date: Fri, 13 Sep 2002 23:11:36 +0900
From: Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
Subject: [webrickja:53] http_version
To: webrickja@notwork.org
Message-Id: <20020913230952.97DE.ZN@mbf.nifty.com>
X-Mail-Count: 00053

西山和広です。

lib/webrick/httprequest.rbの

    def read_request_line(socket)
      @request_line = read_line(socket) if socket
      @request_time = Time.now
      raise HTTPStatus::EOFError unless @request_line
      if /^(\S+)\s+(\S+)(\s+HTTP\/(\d+\.\d+))?/o =~ @request_line
        @request_method = $1
        @unparsed_uri   = $2
        @http_version   = $4 ? $4.to_f : 0.9

の処理がまずいです。

http://www.ietf.org/rfc/rfc2616.txt
3 Protocol Parameters
3.1 HTTP Version
|    The version of an HTTP message is indicated by an HTTP-Version field
|    in the first line of the message.
| 
|        HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT
| 
|    Note that the major and minor numbers MUST be treated as separate
|    integers and that each MAY be incremented higher than a single digit.
|    Thus, HTTP/2.4 is a lower version than HTTP/2.13, which in turn is
|    lower than HTTP/12.3. Leading zeros MUST be ignored by recipients and
|    MUST NOT be sent.

HTTP/2.4 < HTTP/2.13 や HTTP/1.01 == HTTP/1.1 < HTTP/1.02 と
なるべきなので、Floatでは扱えないです。

http://www.ietf.org/rfc/rfc2145.txt
2.3 Which version number to send in a message
|   at least conditionally compliant.  A server MAY send a 505 (HTTP
|   Version Not Supported) response if cannot send a response using the
|   major version used in the client's request.

HTTP/2.0 などでは 505 を返すべきです。


-- 
|ZnZ(ゼット エヌ ゼット)
|西山和広(Kazuhiro NISHIYAMA)