Skip to content
This repository was archived by the owner on Apr 17, 2024. It is now read-only.

Allow file reading in the middle of request body #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions restclient.el
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,16 @@ The buffer contains the raw HTTP response sent by the server."
(insert-file-contents path)
(buffer-string)))

(defun restclient-replace-path-with-contents (entity)
(replace-regexp-in-string
restclient-file-regexp
(lambda (match)
(string-match restclient-file-regexp match)
(restclient-read-file (match-string 1 match)))
entity))

(defun restclient-parse-body (entity vars)
(if (= 0 (or (string-match restclient-file-regexp entity) 1))
(restclient-read-file (match-string 1 entity))
(restclient-replace-all-in-string vars entity)))
(restclient-replace-path-with-contents (restclient-replace-all-in-string vars entity)))

(defun restclient-parse-hook (cb-type args-offset args)
(if-let ((handler (assoc cb-type restclient-result-handlers)))
Expand Down