All pastes #53335 Raw Edit

elisp and sockets

public text v1 · immutable
#53335 ·published 2006-05-03 21:56 UTC
rendered paste body
;; A nice function to show off. Gets some HTTP headers.
(defun webinfo (host)  (interactive "sHost: ")
  (with-output-to-temp-buffer "*webinfo*"
    (let ((s (open-network-stream (format "webinfo-%s" host) nil host "http")))
      (when s
        (unwind-protect
            (progn
              (set-process-filter s (lambda (o p) (princ (delete 13 p))))
              (process-send-string s "HEAD / HTTP/1.0\r\n\r\n")
              (while (eq (process-status s) 'open)
                (sit-for 0.01)))
          (delete-process s))))))