This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu*** glibc detected *** /usr/bin/newlisp: double free or corruption (fasttop): 0xQuote
#!/usr/bin/newlisp
(constant 'max-bytes 1024)
(define (error num)
(format "Error: %d" num))
(define (process-request request)
(set 'request (parse request " "))
(case (first request)
("GET" (get-request (request 1)))
("HEAD" (create-head (request 1)))
(true (error 501))))
(define (get-request item)
(set 'item (replace "../" item ""))
(if (ends-with item {.css|.html} 1) (send-file (1 item))
(string "file not allowedn")))
(define (send-file filename)
(if (file? filename) (read-file filename)
(error 404)))
(define (create-head item)
(string "head"))
;
; PROGRAM START
;
(if (not (setf listen (net-listen 8080)))
(print (net-error)))
(while (not (net-error))
(setf connection (net-accept listen))
(net-receive connection message max-bytes)
(net-send connection (process-request message))
(close connection))
;(while true
; (print (process-request "GET /test.html")))
(exit)
echo "GET /test.html" | nc localhost 8080