zweifisch / ob-http

make http request within org-mode babel
GNU General Public License v3.0
256 stars 30 forks source link

ob-http: (wrong-type-argument stringp nil) #22

Open olbohlen opened 8 years ago

olbohlen commented 8 years ago

Hi,

I'm using org-mode 8.3.4 and ob-http cloned today from github. When trying the example:

+NAME:ob-languages

+BEGIN_SRC http :pretty

GET https://api.github.com/repos/zweifisch/ob-http/languages

+END_SRC

I get: Debugger entered--Lisp error: (wrong-type-argument stringp nil) string-match("json" nil) (cond ((string-match "json" content-type) (quote json)) ((string-match "html" content-type) (quote html)) ((string-match "xml" content-type) (quote xml))) ob-http-parse-content-type(nil) (let ((--cl-var-- (ob-http-parse-content-type content-type))) (cond ((eql --cl-var-- (quote json)) (ob-http-pretty-json body)) ((eql --cl-var-- (quote xml)) (ob-http-pretty-xml body)) ((eql --cl-var-- (quote html)) (ob-http-pretty-html body)) (t body))) (if (string= "" body) body (let ((--cl-var-- (ob-http-parse-content-type content-type))) (cond ((eql --cl-var-- (quote json)) (ob-http-pretty-json body)) ((eql --cl-var-- (quote xml)) (ob-http-pretty-xml body)) ((eql --cl-var-- (quote html)) (ob-http-pretty-html body)) (t body)))) ob-http-pretty("HTTP/1.1 200 OK \nServer: GitHub.com \nDate: Wed, 06 Jul 2016 08:08:23 GMT \nContent-Type: application/json; charset=utf-8 \nContent-Length: 42 \nStatus: 200 OK \nX-RateLimit-Limit: 60 \nX-RateLimit-Remaining: 58 \nX-RateLimit-Reset: 1467796069 \nCache-Control: public, max-age=60, s-maxage=60 \nVary: Accept \nETag: \"fd8d090f6f47b24552b886d3a0983abd\" \nLast-Modified: Tue, 14 Jun 2016 11:58:21 GMT \nX-GitHub-Media-Type: github.v3 \nAccess-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval \nAccess-Control-Allow-Origin: \nContent-Security-Policy: default-src 'none' \nStrict-Transport-Security: max-age=31536000; includeSubdomains; preload \nX-Content-Type-Options: nosniff \nX-Frame-Options: deny \nX-XSS-Protection: 1; mode=block \nVary: Accept-Encoding \nX-Served-By: 7b641bda7ec2ca7cd9df72d2578baf75 \nX-GitHub-Request-Id: D4067D5A:2F35:BD4C762:577CBC77 \n \n{\n \"Emacs Lisp\": 13730,\n \"Shell\": 139\n}\n" nil) (aset v 2 (ob-http-pretty (progn (or (and (vectorp response) (>= (length response) 4) (memq (aref response 0) cl-struct-ob-http-response-tags)) (error "%s accessing a non-%s" (quote ob-http-response-body) (quote ob-http-response))) (aref response 2)) (if (member content-type (quote ("yes" nil))) (ob-http-get-response-header response "content-type") content-type))) (let* ((v response)) (aset v 2 (ob-http-pretty (progn (or (and (vectorp response) (>= (length response) 4) (memq (aref response 0) cl-struct-ob-http-response-tags)) (error "%s accessing a non-%s" (quote ob-http-response-body) (quote ob-http-response))) (aref response 2)) (if (member content-type (quote ("yes" nil))) (ob-http-get-response-header response "content-type") content-type)))) (progn (or (and (vectorp response) (>= (length response) 4) (memq (aref response 0) cl-struct-ob-http-response-tags)) (error "%s accessing a non-%s" (quote ob-http-response-body) (quote ob-http-response))) (let* ((v response)) (aset v 2 (ob-http-pretty (progn (or (and (vectorp response) (>= ... 4) (memq ... cl-struct-ob-http-response-tags)) (error "%s accessing a non-%s" (quote ob-http-response-body) (quote ob-http-response))) (aref response 2)) (if (member content-type (quote ("yes" nil))) (ob-http-get-response-header response "content-type") content-type))))) ob-http-pretty-response([cl-struct-ob-http-response "HTTP/1.1 200 Connection established \nConnection: close" "HTTP/1.1 200 OK \nServer: GitHub.com \nDate: Wed, 06 Jul 2016 08:08:23 GMT \nContent-Type: application/json; charset=utf-8 \nContent-Length: 42 \nStatus: 200 OK \nX-RateLimit-Limit: 60 \nX-RateLimit-Remaining: 58 \nX-RateLimit-Reset: 1467796069 \nCache-Control: public, max-age=60, s-maxage=60 \nVary: Accept \nETag: \"fd8d090f6f47b24552b886d3a0983abd\" \nLast-Modified: Tue, 14 Jun 2016 11:58:21 GMT \nX-GitHub-Media-Type: github.v3 \nAccess-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval \nAccess-Control-Allow-Origin: \nContent-Security-Policy: default-src 'none' \nStrict-Transport-Security: max-age=31536000; includeSubdomains; preload \nX-Content-Type-Options: nosniff \nX-Frame-Options: deny \nX-XSS-Protection: 1; mode=block \nVary: Accept-Encoding \nX-Served-By: 7b641bda7ec2ca7cd9df72d2578baf75 \nX-GitHub-Request-Id: D4067D5A:2F35:BD4C762:577CBC77 \n \n{\n \"Emacs Lisp\": 13730,\n \"Shell\": 139\n}\n" (("http/1.1 200 connection established") ("connection" . "close"))] nil) (progn (ob-http-pretty-response response (cdr pretty))) (if prettify (progn (ob-http-pretty-response response (cdr pretty)))) (let ((response (ob-http-parse-response (buffer-string)))) (if prettify (progn (ob-http-pretty-response response (cdr pretty)))) (if ob-http:remove-cr (progn (ob-http-remove-carriage-return response))) (cond (get-header (ob-http-get-response-header response get-header)) (select (ob-http-select response select)) (prettify (progn (or (and (vectorp response) (>= (length response) 4) (memq (aref response 0) cl-struct-ob-http-response-tags)) (error "%s accessing a non-%s" (quote ob-http-response-body) (quote ob-http-response))) (aref response 2))) (file (ob-http-file response (cdr file))) (t (s-join "\n\n" (list (progn (or (and ... ... ...) (error "%s accessing a non-%s" ... ...)) (aref response 1)) (progn (or (and ... ... ...) (error "%s accessing a non-%s" ... ...)) (aref response 2))))))) (if (= 0 (apply (quote call-process) "curl" nil (list t error-output) nil (ob-http-flatten args))) (let ((response (ob-http-parse-response (buffer-string)))) (if prettify (progn (ob-http-pretty-response response (cdr pretty)))) (if ob-http:remove-cr (progn (ob-http-remove-carriage-return response))) (cond (get-header (ob-http-get-response-header response get-header)) (select (ob-http-select response select)) (prettify (progn (or (and (vectorp response) (>= ... 4) (memq ... cl-struct-ob-http-response-tags)) (error "%s accessing a non-%s" (quote ob-http-response-body) (quote ob-http-response))) (aref response 2))) (file (ob-http-file response (cdr file))) (t (s-join "\n\n" (list (progn (or ... ...) (aref response 1)) (progn (or ... ...) (aref response 2))))))) (let* ((old-dir default-directory) (buf (save-current-buffer (set-buffer (get-buffer-create "curl error")) (prog1 (current-buffer) (kill-all-local-variables) (setq default-directory old-dir) (setq buffer-read-only nil) (setq buffer-file-name nil) (setq buffer-undo-list t) (let (... ...) (erase-buffer) (run-hooks ...))))) (standard-output buf)) (prog1 (progn (princ (let ((temp-buffer ...)) (save-current-buffer (set-buffer temp-buffer) (unwind-protect ... ...)))) "") (internal-temp-output-buffer-show buf)))) (save-current-buffer (set-buffer (get-buffer-create "curl output")) (erase-buffer) (if (= 0 (apply (quote call-process) "curl" nil (list t error-output) nil (ob-http-flatten args))) (let ((response (ob-http-parse-response (buffer-string)))) (if prettify (progn (ob-http-pretty-response response (cdr pretty)))) (if ob-http:remove-cr (progn (ob-http-remove-carriage-return response))) (cond (get-header (ob-http-get-response-header response get-header)) (select (ob-http-select response select)) (prettify (progn (or (and ... ... ...) (error "%s accessing a non-%s" ... ...)) (aref response 2))) (file (ob-http-file response (cdr file))) (t (s-join "\n\n" (list (progn ... ...) (progn ... ...)))))) (let* ((old-dir default-directory) (buf (save-current-buffer (set-buffer (get-buffer-create "curl error")) (prog1 (current-buffer) (kill-all-local-variables) (setq default-directory old-dir) (setq buffer-read-only nil) (setq buffer-file-name nil) (setq buffer-undo-list t) (let ... ... ...)))) (standard-output buf)) (prog1 (progn (princ (let (...) (save-current-buffer ... ...))) "") (internal-temp-output-buffer-show buf))))) (let* ((request (ob-http-parse-request (org-babel-expand-body:http body params))) (proxy (cdr (assoc :proxy params))) (noproxy (assoc :noproxy params)) (follow-redirect (and (assoc :follow-redirect params) (not (string= "no" (cdr (assoc :follow-redirect params)))))) (pretty (assoc :pretty params)) (prettify (and pretty (not (string= (cdr pretty) "no")))) (file (assoc :file params)) (get-header (cdr (assoc :get-header params))) (cookie-jar (cdr (assoc :cookie-jar params))) (cookie (cdr (assoc :cookie params))) (curl (cdr (assoc :curl params))) (select (cdr (assoc :select params))) (request-body (progn (or (and (vectorp request) (>= (length request) 5) (memq (aref request 0) cl-struct-ob-http-request-tags)) (error "%s accessing a non-%s" (quote ob-http-request-body) (quote ob-http-request))) (aref request 4))) (error-output (org-babel-temp-file "curl-error")) (args (append ob-http:curl-custom-arguments (list "-i" (if (and proxy (not noproxy)) (progn (list "-x" proxy))) (if noproxy (progn (quote ...))) (let ((method ...)) (if (string= "HEAD" method) "-I" (list "-X" method))) (if follow-redirect (progn "-L")) (mapcar (function (lambda ... ...)) (progn (or ... ...) (aref request 3))) (if (s-present\? request-body) (progn (let ... ... ...))) (if cookie-jar (progn (list "--cookie-jar" cookie-jar))) (if cookie (progn (list "--cookie" cookie))) (if curl (progn (split-string-and-unquote curl))) "--max-time" (int-to-string (or (cdr ...) ob-http:max-time)) (ob-http-construct-url (progn (or ... ...) (aref request 2)) params))))) (save-current-buffer (set-buffer (get-buffer-create "curl commands history")) (goto-char (point-max)) (let ((cmd-line (concat "curl " (string-join (ob-http-flatten args) " ") "\n"))) (insert (replace-regexp-in-string "--noproxy _" "--noproxy '_'" cmd-line)))) (save-current-buffer (set-buffer (get-buffer-create "curl output")) (erase-buffer) (if (= 0 (apply (quote call-process) "curl" nil (list t error-output) nil (ob-http-flatten args))) (let ((response (ob-http-parse-response (buffer-string)))) (if prettify (progn (ob-http-pretty-response response (cdr pretty)))) (if ob-http:remove-cr (progn (ob-http-remove-carriage-return response))) (cond (get-header (ob-http-get-response-header response get-header)) (select (ob-http-select response select)) (prettify (progn (or ... ...) (aref response 2))) (file (ob-http-file response (cdr file))) (t (s-join "\n\n" (list ... ...))))) (let* ((old-dir default-directory) (buf (save-current-buffer (set-buffer ...) (prog1 ... ... ... ... ... ... ...))) (standard-output buf)) (prog1 (progn (princ (let ... ...)) "") (internal-temp-output-buffer-show buf)))))) org-babel-execute:http("GET https://api.github.com/repos/zweifisch/ob-http/languages" ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:session . "none") (:hlines . "no") (:pretty) (:result-type . value) (:result-params "replace") (:rowname-names) (:colname-names))) funcall(org-babel-execute:http "GET https://api.github.com/repos/zweifisch/ob-http/languages" ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:session . "none") (:hlines . "no") (:pretty) (:result-type . value) (:result-params "replace") (:rowname-names) (:colname-names))) (let ((result (funcall cmd body params))) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result)) (setq result (let ((result (funcall cmd body params))) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result))) (if (member "none" result-params) (progn (funcall cmd body params) (message "result silenced") (setq result nil)) (setq result (let ((result (funcall cmd body params))) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result))) (if (cdr (assoc :file params)) (progn (if result (progn (let ((temp-file ...) (temp-buffer ...)) (unwind-protect (prog1 ... ...) (and ... ...))))) (setq result (cdr (assoc :file params))))) (if (cdr (assoc :post params)) (progn (let ((this (if (cdr ...) (org-babel-result-to-file ... ...) result))) (setq result (org-babel-ref-resolve (cdr (assoc :post params)))) (if (cdr (assoc :file params)) (progn (setq result-params (remove "file" result-params))))))) (org-babel-insert-result result result-params info new-hash indent lang)) (let ((call-process-region (function (lambda (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))))) (let ((lang-check (function (lambda (f) (let (...) (if ... ...)))))) (setq cmd (or (funcall lang-check lang) (funcall lang-check (symbol-name (cdr (assoc lang org-src-lang-modes)))) (error "No org-babel-execute function for %s!" lang)))) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (if (member "none" result-params) (progn (funcall cmd body params) (message "result silenced") (setq result nil)) (setq result (let ((result (funcall cmd body params))) (if (and (eq (cdr ...) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result))) (if (cdr (assoc :file params)) (progn (if result (progn (let (... ...) (unwind-protect ... ...)))) (setq result (cdr (assoc :file params))))) (if (cdr (assoc :post params)) (progn (let ((this (if ... ... result))) (setq result (org-babel-ref-resolve (cdr ...))) (if (cdr (assoc :file params)) (progn (setq result-params ...)))))) (org-babel-insert-result result result-params info new-hash indent lang)) (run-hooks (quote org-babel-after-execute-hook)) result) (unwind-protect (let ((call-process-region (function (lambda (&rest args) (apply (quote org-babel-tramp-handle-call-process-region) args))))) (let ((lang-check (function (lambda (f) (let ... ...))))) (setq cmd (or (funcall lang-check lang) (funcall lang-check (symbol-name (cdr ...))) (error "No org-babel-execute function for %s!" lang)))) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (if (member "none" result-params) (progn (funcall cmd body params) (message "result silenced") (setq result nil)) (setq result (let ((result (funcall cmd body params))) (if (and (eq ... ...) (or ... ...) (not ...)) (list (list result)) result))) (if (cdr (assoc :file params)) (progn (if result (progn (let ... ...))) (setq result (cdr (assoc :file params))))) (if (cdr (assoc :post params)) (progn (let ((this ...)) (setq result (org-babel-ref-resolve ...)) (if (cdr ...) (progn ...))))) (org-babel-insert-result result result-params info new-hash indent lang)) (run-hooks (quote org-babel-after-execute-hook)) result) (setq call-process-region (quote org-babel-call-process-region-original))) (let* ((lang (nth 0 info)) (result-params (cdr (assoc :result-params params))) (body (let* ((c (nthcdr 1 info))) (setcar c (if (org-babel-noweb-p params :eval) (org-babel-expand-noweb-references info) (nth 1 info))))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory (expand-file-name dir))) default-directory)) (org-babel-call-process-region-original (or (and (boundp (quote org-babel-call-process-region-original)) org-babel-call-process-region-original) (symbol-function (quote call-process-region)))) (indent (nth 5 info)) result cmd) (unwind-protect (let ((call-process-region (function (lambda (&rest args) (apply ... args))))) (let ((lang-check (function (lambda ... ...)))) (setq cmd (or (funcall lang-check lang) (funcall lang-check (symbol-name ...)) (error "No org-babel-execute function for %s!" lang)))) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (if (member "none" result-params) (progn (funcall cmd body params) (message "result silenced") (setq result nil)) (setq result (let ((result ...)) (if (and ... ... ...) (list ...) result))) (if (cdr (assoc :file params)) (progn (if result (progn ...)) (setq result (cdr ...)))) (if (cdr (assoc :post params)) (progn (let (...) (setq result ...) (if ... ...)))) (org-babel-insert-result result result-params info new-hash indent lang)) (run-hooks (quote org-babel-after-execute-hook)) result) (setq call-process-region (quote org-babel-call-process-region-original)))) (cond (cache-current-p (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " ") (let ((result (org-babel-read-result))) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result))) ((org-babel-confirm-evaluate (let ((i info)) (let* ((c (nthcdr 2 i))) (setcar c merged-params)) i)) (let* ((lang (nth 0 info)) (result-params (cdr (assoc :result-params params))) (body (let* ((c ...)) (setcar c (if ... ... ...)))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory ...)) default-directory)) (org-babel-call-process-region-original (or (and (boundp ...) org-babel-call-process-region-original) (symbol-function (quote call-process-region)))) (indent (nth 5 info)) result cmd) (unwind-protect (let ((call-process-region (function ...))) (let ((lang-check ...)) (setq cmd (or ... ... ...))) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" ...) "")) (if (member "none" result-params) (progn (funcall cmd body params) (message "result silenced") (setq result nil)) (setq result (let ... ...)) (if (cdr ...) (progn ... ...)) (if (cdr ...) (progn ...)) (org-babel-insert-result result result-params info new-hash indent lang)) (run-hooks (quote org-babel-after-execute-hook)) result) (setq call-process-region (quote org-babel-call-process-region-original)))))) (let* ((params (if params (org-babel-process-params merged-params) (nth 2 info))) (cachep (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) (new-hash (if cachep (progn (org-babel-sha1-hash info)))) (old-hash (if cachep (progn (org-babel-current-result-hash)))) (cache-current-p (and (not arg) new-hash (equal new-hash old-hash)))) (cond (cache-current-p (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " ") (let ((result (org-babel-read-result))) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result))) ((org-babel-confirm-evaluate (let ((i info)) (let* ((c ...)) (setcar c merged-params)) i)) (let* ((lang (nth 0 info)) (result-params (cdr (assoc :result-params params))) (body (let* (...) (setcar c ...))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir ...) default-directory)) (org-babel-call-process-region-original (or (and ... org-babel-call-process-region-original) (symbol-function ...))) (indent (nth 5 info)) result cmd) (unwind-protect (let ((call-process-region ...)) (let (...) (setq cmd ...)) (message "executing %s code block%s..." (capitalize lang) (if ... ... "")) (if (member "none" result-params) (progn ... ... ...) (setq result ...) (if ... ...) (if ... ...) (org-babel-insert-result result result-params info new-hash indent lang)) (run-hooks (quote org-babel-after-execute-hook)) result) (setq call-process-region (quote org-babel-call-process-region-original))))))) (progn (let* ((params (if params (org-babel-process-params merged-params) (nth 2 info))) (cachep (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) (new-hash (if cachep (progn (org-babel-sha1-hash info)))) (old-hash (if cachep (progn (org-babel-current-result-hash)))) (cache-current-p (and (not arg) new-hash (equal new-hash old-hash)))) (cond (cache-current-p (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " ") (let ((result ...)) (message (replace-regexp-in-string "%" "%%" ...)) result))) ((org-babel-confirm-evaluate (let ((i info)) (let* (...) (setcar c merged-params)) i)) (let* ((lang (nth 0 info)) (result-params (cdr ...)) (body (let* ... ...)) (dir (cdr ...)) (default-directory (or ... default-directory)) (org-babel-call-process-region-original (or ... ...)) (indent (nth 5 info)) result cmd) (unwind-protect (let (...) (let ... ...) (message "executing %s code block%s..." ... ...) (if ... ... ... ... ... ...) (run-hooks ...) result) (setq call-process-region (quote org-babel-call-process-region-original)))))))) (if (org-babel-check-evaluate (let ((i info)) (let* ((c (nthcdr 2 i))) (setcar c merged-params)) i)) (progn (let* ((params (if params (org-babel-process-params merged-params) (nth 2 info))) (cachep (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr ...)))) (new-hash (if cachep (progn (org-babel-sha1-hash info)))) (old-hash (if cachep (progn (org-babel-current-result-hash)))) (cache-current-p (and (not arg) new-hash (equal new-hash old-hash)))) (cond (cache-current-p (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " ") (let (...) (message ...) result))) ((org-babel-confirm-evaluate (let (...) (let* ... ...) i)) (let* ((lang ...) (result-params ...) (body ...) (dir ...) (default-directory ...) (org-babel-call-process-region-original ...) (indent ...) result cmd) (unwind-protect (let ... ... ... ... ... result) (setq call-process-region ...)))))))) (let* ((org-babel-current-src-block-location (or org-babel-current-src-block-location (nth 6 info) (org-babel-where-is-src-block-head) (and (org-babel-get-inline-src-block-matches) (match-beginning 0)))) (info (if info (copy-tree info) (org-babel-get-src-block-info))) (merged-params (org-babel-merge-params (nth 2 info) params))) (if (org-babel-check-evaluate (let ((i info)) (let* ((c (nthcdr 2 i))) (setcar c merged-params)) i)) (progn (let* ((params (if params (org-babel-process-params merged-params) (nth 2 info))) (cachep (and (not arg) (cdr ...) (string= "yes" ...))) (new-hash (if cachep (progn ...))) (old-hash (if cachep (progn ...))) (cache-current-p (and (not arg) new-hash (equal new-hash old-hash)))) (cond (cache-current-p (save-excursion (goto-char ...) (forward-line) (skip-chars-forward " ") (let ... ... result))) ((org-babel-confirm-evaluate (let ... ... i)) (let* (... ... ... ... ... ... ... result cmd) (unwind-protect ... ...)))))))) org-babel-execute-src-block(nil) (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg) t) (if (or (org-babel-where-is-src-block-head) (org-babel-get-inline-src-block-matches)) (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg) t) nil) org-babel-execute-src-block-maybe() (or (org-babel-execute-src-block-maybe) (org-babel-lob-execute-maybe)) org-babel-execute-maybe() (if org-babel-no-eval-on-ctrl-c-ctrl-c nil (org-babel-execute-maybe)) org-babel-execute-safely-maybe() run-hook-with-args-until-success(org-babel-execute-safely-maybe) (cond ((or (and (boundp (quote org-clock-overlays)) org-clock-overlays) org-occur-highlights) (and (boundp (quote org-clock-overlays)) (org-clock-remove-overlays)) (org-remove-occur-highlights) (message "Temporary highlights/overlays removed from current buffer")) ((and (local-variable-p (quote org-finish-function) (current-buffer)) (fboundp org-finish-function)) (funcall org-finish-function)) ((run-hook-with-args-until-success (quote org-ctrl-c-ctrl-c-hook))) (t (if (save-excursion (beginning-of-line) (looking-at "[ ]$")) (or (run-hook-with-args-until-success (quote org-ctrl-c-ctrl-c-final-hook)) (user-error "C-c C-c can do nothing useful at this location")) (let ((context (org-element-context)) (type (org-element-type context))) (cond ((eql type (quote link)) (setq context (org-element-property :parent context)) (setq type (org-element-type context))) ((memql type (quote ...)) (setq context (org-element-lineage context ...)))) (if (eq type (quote paragraph)) (progn (let (...) (if ... ...)))) (cond ((eql type (quote clock)) (org-clock-update-time-maybe)) ((eql type (quote dynamic-block)) (save-excursion (goto-char ...) (org-update-dblock))) ((eql type (quote footnote-definition)) (goto-char (org-element-property :post-affiliated context)) (call-interactively (quote org-footnote-action))) ((eql type (quote footnote-reference)) (call-interactively (quote org-footnote-action))) ((memql type (quote ...)) (save-excursion (goto-char ...) (call-interactively ...))) ((eql type (quote item)) (let* (... ... ... ... ... ...) (org-list-set-checkbox ... struct ...) (org-list-struct-fix-ind struct parents 2) (org-list-struct-fix-item-end struct) (org-list-struct-fix-bul struct prevs) (org-list-struct-fix-ind struct parents) (let ... ... ...))) ((eql type (quote keyword)) (let (... ...) (if ... ...) (let ... ... --rtn)) (message "Local setup has been refreshed")) ((eql type (quote plain-list)) (let* (... ... ... ... ... ...) (cond ... ...) (org-list-write-struct struct ... old-struct) (org-update-checkbox-count-maybe) (save-excursion ... ...))) ((memql type (quote ...)) (call-interactively (quote org-property-action))) ((memql type (quote ...)) (call-interactively (quote org-update-radio-target-regexp))) ((eql type (quote statistics-cookie)) (call-interactively (quote org-update-statistics-cookies))) ((memql type (quote ...)) (if (eq ... ...) (message "%s" ...) (let ... ...))) ((eql type (quote timestamp)) (org-timestamp-change 0 (quote day))) (t (or (run-hook-with-args-until-success ...) (user-error "C-c C-c can do nothing useful at this location")))))))) org-ctrl-c-ctrl-c(nil) call-interactively(org-ctrl-c-ctrl-c nil nil)

I don't get what's going wrong here...could you please enlighten me?

Regards,

Olaf

zweifisch commented 8 years ago

I've just pushed a commit 47a7b367314f6051715882e46a0e40477bda20a2, which will hopefully fix the error, but I have no clue why it failed to get the content-type header.

olbohlen commented 8 years ago

well, I can retrieve data now, but I also get the http headers (with nasty ^M):

#+NAME:ob-languages
#+BEGIN_SRC http :pretty
  GET https://api.github.com/repos/zweifisch/ob-http/languages
#+END_SRC

#+results: ob-languages
#+begin_example
HTTP/1.1 200 OK
Server: GitHub.com
Date: Fri, 29 Jul 2016 07:14:17 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 42
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 44
X-RateLimit-Reset: 1469778714
Cache-Control: public, max-age=60, s-maxage=60
Vary: Accept
ETag: "90b0e83d5c2ec8d29ddba496dc7ff8f3"
Last-Modified: Mon, 25 Jul 2016 12:50:04 GMT
X-GitHub-Media-Type: github.v3
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'none'
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
Vary: Accept-Encoding
X-Served-By: d594a23ec74671eba905bf91ef329026
X-GitHub-Request-Id: D4067D5A:55FE:4375BA8:579B0249

{
  "Emacs Lisp": 13760,
  "Shell": 139
}
#+end_example
laat commented 8 years ago

There is a defcustom ob-http:remove-cr that removes the ^M from results

(setq ob-http:remove-cr t) should do the trick

olbohlen commented 8 years ago

right, but it doesn't - and I should not get the headers printed at all, if I am right...