Last active
December 15, 2015 12:39
-
-
Save kakakikikeke/5262112 to your computer and use it in GitHub Desktop.
emacsでHTTP Requestを送信、取得するためのelispです。デフォルトemacsに入っている url パッケージを使っています。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'url) | |
(defun send-http-request (url) | |
"Send a simple http request and open a result within an other buffer.." | |
(let | |
( | |
(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) | |
(switch-to-buffer | |
(current-buffer))) | |
(defun get-response (url) | |
"Get the http response info." | |
(let | |
( | |
(url-request-method "GET") | |
(url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded"))) | |
(buffer (url-retrieve-synchronously url))) | |
(save-excursion | |
(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