I was trying to make use of read-http-request in httpio.scm to parse a HTTP request from a TCP socket, but got stuck with what seems like a bug along the way:
read-http-request attempts to parse the initial request line using parse-request-line, which crashes on the following:
(*parse-string parse-request-line "GET / HTTP/1.1")
However, it works fine with absolute URIs:
If I'm not completely mistaken it seems like the cause is url.scm:parse-uri-path-absolute attempting to create a URI record with only a scheme, an authority and a path - without a query or fragment. Because of this it crashes with the following error, from encapsulate-uri in url.scm:
"The object 3, passed as the second argument to vector-ref, is not in the correct range."
Changing parse-request-line to instead alternate between only parse-uri and parse-uri-authority seems to resolve the issue, as parse-uri correctly handles absolute HTTP paths using parser:relative-ref. I might be missing a case or two here though.
Note that I couldn't find any usage of read-http-request elsewhere at all, so I apologize if this isn't the intended usage of it.
Regards Martin Ek