Arc Forumnew | comments | leaders | submitlogin
3 points by stefano 5924 days ago | link | parent

Seems like something weird is going on with 'readline: a call to the last header line (which should be a line made only of "\r\n") reads a line starting with a newline (something that shouldn't happen). For example for news.ycombinator.com it reads "\n<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"http://ycombinator.com/news.css\">" instead of an empty line. As a consequence, the header terminator isn't found and the whole page is considered as an header, thus failing to parse it. I wonder why...


4 points by almkglor 5924 days ago | link

It seems partly a problem with srv.arc, it seems it doesn't correctly use \r\n, only \n ~.~;

See in srv.arc:

    (def header ((o type textmime*) (o code 200))
      (string "HTTP/1.0 " code " " (statuscodes* code) "
    " serverheader* "
    Content-Type: " type "
    Connection: close"))
Inspecting the file, they seem to be \n's only, not \r\n

A second problem lies in 'readline:

    (def readline ((o str (stdin)))
      " Reads a string terminated by a newline from the stream `str'. "
      (awhen (readc str)
        (tostring
          (writec it)
          (whiler c (readc str) #\newline
            (writec c)))))
It has to do with the fact that it reads in a character, BUT DOESN'T CHECK THAT THAT FIRST CHARACTER IS A NEWLINE. The only check done is with the second character read.

Will fix.

-----

2 points by cchooper 5924 days ago | link

You fixed it! Thanks!

-----