/ Published in: Lisp
URL: http://bcmoney-mobiletv.com/blog/2009/05/01/the-server-side-proxy/
http://cl-cookbook.sourceforge.net/sockets.html#example
Expand |
Embed | Plain Text
(defun http-get (server port path) "Send a request for file `path' to an HTTP/0.9 server on host `server', port number `port'. Print the contents of the returned file to standard output." ;; Open connection (let ((socket (open-socket server port))) (unwind-protect (progn (format t "> Sending request to ~a:~a...~%" server port) ;; Send request (http-send-line socket (format nil "GET ~a HTTP/0.9~%~%" path)) (force-output socket) ;; Read response and output it (format t "> Received response:~%") (loop (let ((line (read-line socket nil nil))) (unless line (return)) (format t "~a~%" line)))) ;; Close socket before exiting. (close socket))))
You need to login to post a comment.
