Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make POST requests use external-format-out for multipart/form-data.

With this change, POST requests that use multipart/form-data will use
external-format-out for encoding, instead of :latin-1. Without this
change, an attempt to use characters outside the :latin-1 range (e.g,
U+2011, "n-dash") would cause an exception while building the request.

Note: it would be possible to only do this for strings that have
characters that are not standard-char.
  • Loading branch information...
commit afa31400efd42080477d9c9c64acba4e5e7245e4 1 parent 1728e3f
@rwiker rwiker authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 request.lisp
View
10 request.lisp
@@ -86,7 +86,7 @@ depending on the type of CONTENT."
(funcall content stream))
(t (parameter-error "Don't know how to send content ~S to server." content)))))
-(defun make-form-data-function (parameters boundary)
+(defun make-form-data-function (parameters boundary external-format-out)
"Creates and returns a closure which can be used as an argument for
SEND-CONTENT to send PARAMETERS as a `multipart/form-data' request
body using the boundary BOUNDARY."
@@ -106,8 +106,12 @@ body using the boundary BOUNDARY."
(crlf)
(format stream "Content-Disposition: form-data; name=\"~A\"" name)
(cond ((stringp value)
+ (crlf)
+ (format stream "Content-Type: text/plain; charset=~a" external-format-out)
(crlf) (crlf)
- (format stream "~A" value))
+ (setf (flexi-stream-external-format stream) external-format-out)
+ (format stream "~A" value)
+ (setf (flexi-stream-external-format stream) +latin-1+)
((and (listp value)
(first value)
(not (stringp (first value))))
@@ -499,7 +503,7 @@ PARAMETERS will not be used."
(setq parameters-used-p t)
(cond ((or form-data file-parameters-p)
(let ((boundary (format nil "----------~A" (make-random-string))))
- (setq content (make-form-data-function parameters boundary)
+ (setq content (make-form-data-function parameters boundary external-format-out)
content-type (format nil "multipart/form-data; boundary=~A" boundary)))
(unless (or file-parameters-p content-length-provided-p)
(setq content-length (or content-length t))))
Please sign in to comment.
Something went wrong with that request. Please try again.