| I was looking through the srv code today and noticed a few things I'd like to fix. First of all if a url is not found a message like "Unknown operator" is returned but the status code is 200. This doesn't seem right. Instead of adding an err-header* to match the existing header strings:   (= header* "HTTP/1.0 200 OK
  Content-Type: text/html
  Connection: close")
  (= gif-header* "HTTP/1.0 200 OK
  Content-Type: image/gif
  Connection: close")
 
I changed how this code worked so the string would be generated from a function:  (= statuscodes* (listtab '((200 "OK") (302 "Moved Temporarily") (404 "Not Found") (500 "Internal Server Error"))))
  (def header ((o type "text/html") (o code 200))
    (string "HTTP/1.0 " code " " (statuscodes* code) "
  Content-Type: " type "
  Connection: close"))
 
For convenience also:  (def err-header ((o code 404))
    (header "text/html" code))
 
Now in the request handling code instead of:  (prn gif-header*)
  ; or
  (prn header*)
 
it's now:  (prn (header "image/gif"))
  ; and
  (prn (header))
 
And most importantly inside respond-err it's now:  (prn (err-header))
  ; instead of 
  (prn header*) ; original bug
 
Additionally I'd like to change respond-err to take another parm which would be the code to distinguish between 404s and 500s, but for now they're all 404s.How does all this sound?  |