spork/http errors #1348
-
I'm a long time Python programmer (28 years). I've been studying Emacs lisp and SBCl for a a few years now as well. Discovered Janet a couple of months ago, and it's fantastic. I am working on an image gallery to learn. I wrote it in Python first, and then in Janet. I got it working with circlet, but then while improving the code, I saw a thread that recommended using spork/http instead. So yesterday, I converted the circlet version to use spork/http, which was not difficult. It is working, but not 100% reliably. Sometimes it fails to delivery an image (whether that be a thumbnail, or the full size image). Whether it succeeds or fails, I always get the error below in the terminal where the server is running:
My Janet version is 1.32.1-a10b4f61 Thanks for any insight into this error. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Not sure if the following will help, but FWIW, below are some observations having looked at spork/http a bit. ATM line 328 in send-response (a line mentioned in the stack trace above) has the code: (write-body conn buf (in response :body))) May be the error comes about because Some evidence that supports this thinking:
Looking around for calls to # Do something with request header
(def response (handler req))
# Now send back response
(send-response conn response @""))) If the last line is where the relevant call to A bit further up in [conn handler]
(def handler (middleware handler)) and (defn middleware
"Coerce any type to http middleware"
[x]
(case (type x)
:function x
:number (let [msg (get status-messages x)]
(assert x (string "unknown http status code when making middleware: " x))
(fn mw [&] {:status x :body msg}))
:string (bytes-to-mw x)
:buffer (bytes-to-mw x)
(fn mw [&] x))) Looking at the So perhaps the |
Beta Was this translation helpful? Give feedback.
Hmmm...
Not sure how you have everything hooked up and starting.
Specifically, I wonder about directly using
send-response
. If theimage
function is supposed to be a handler, I think it's typically supposed to return a struct or table.I've put together a little sample with instructions on doing something similar.
Perhaps it might shed some light on what's going on?