Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
emacsでHTTP Requestを送信、取得するためのelispです。デフォルトemacsに入っている url パッケージを使っています。
(require 'url)
(defun send-http-request (url)
"Send a simple http request and open a result within an other buffer.."
(url-request-method "GET")
(url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded"))))
(url-retrieve url 'switch-to-buffer-for-responce)))
(defun switch-to-buffer-for-responce (status)
(defun get-response (url)
"Get the http response info."
(url-request-method "GET")
(url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded")))
(buffer (url-retrieve-synchronously url)))
(set-buffer buffer)
(goto-char (point-min))
(concat (buffer-substring-no-properties (point) (point-max))) )))
(provide 'send-http-request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.