Arc Forumnew | comments | leaders | submitlogin
asv header changes
5 points by byronsalty 6113 days ago | 2 comments
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?



1 point by almkglor 6111 days ago | link

It sounds good. I wonder why it hasn't been pushed to http://git.nex-3.com/?p=arc.git

-----

1 point by byronsalty 6108 days ago | link

updates are going into: http://git.nex-3.com/?p=arc-wiki.git

-----