Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fake a body when it's POST

with-elnode-mock-httpcon: faking a POST requires faking content.
  • Loading branch information...
commit f41a0cf8185e96c72601e7d2c076b3b14861f12e 1 parent 2b1ab9e
Nic Ferrier authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 elnode-testsupport.el
11 elnode-testsupport.el
View
@@ -46,7 +46,16 @@ as `:elnode-http-method'."
`(fakir-mock-process ,symbol ()
(set-process-plist ,symbol (list (make-hash-table :test 'eq)))
(elnode/con-put ,symbol ,@elnode-plist)
- (progn ,@body)))
+ (when (and (equal "POST" (elnode/con-get ,symbol :elnode-http-method))
+ (not (elnode-http-header ,symbol 'content-type)))
+ (let ((hdr-syms (elnode/con-get ,symbol :elnode-http-header-syms))
+ (hdr-strs (elnode/con-get ,symbol :elnode-http-header)))
+ (push (cons 'content-type "multipart/form-data") hdr-syms)
+ (push (cons "content-type" "multipart/form-data") hdr-strs)
+ (elnode/con-put ,symbol :elnode-http-header-syms hdr-syms)
+ (elnode/con-put ,symbol :elnode-http-header hdr-strs)))
+ (noflet ((elnode--http-post-mp-decode (httpcon parsed-type) nil))
+ (progn ,@body))))
(defmacro elnode-mock-con (symbol bindings &rest body)
"Mock an HTTP connection.
Please sign in to comment.
Something went wrong with that request. Please try again.