[bknr-cvs] edi changed trunk/thirdparty/drakma/

BKNR Commits bknr at bknr.net
Mon Dec 14 20:26:57 UTC 2009


Revision: 4487
Author: edi
URL: http://bknr.net/trac/changeset/4487

Parameters without values

U   trunk/thirdparty/drakma/CHANGELOG.txt
U   trunk/thirdparty/drakma/doc/index.html
U   trunk/thirdparty/drakma/request.lisp
U   trunk/thirdparty/drakma/util.lisp

Modified: trunk/thirdparty/drakma/CHANGELOG.txt
===================================================================
--- trunk/thirdparty/drakma/CHANGELOG.txt	2009-12-01 22:49:53 UTC (rev 4486)
+++ trunk/thirdparty/drakma/CHANGELOG.txt	2009-12-14 20:26:57 UTC (rev 4487)
@@ -1,3 +1,5 @@
+Allow for GET/POST parameters without a value (seen on Lotus webservers)
+
 Version 1.1.0
 2009-12-01
 Allowed additional headers to be function designators (suggested by Xiangjun Wu)

Modified: trunk/thirdparty/drakma/doc/index.html
===================================================================
--- trunk/thirdparty/drakma/doc/index.html	2009-12-01 22:49:53 UTC (rev 4486)
+++ trunk/thirdparty/drakma/doc/index.html	2009-12-14 20:26:57 UTC (rev 4487)
@@ -789,7 +789,10 @@
 each being a string) which denotes the parameters which are added to
 the query part of the URI or (in the case of a POST request) comprise
 the request body.  (But
-see <a href="#content"><code><i>content</i></code></a> below.)  The
+see <a href="#content"><code><i>content</i></code></a> below.)
+The values can also be
+<code>NIL</code> in which case only the name (without an equal sign) is used in
+the query string.  The
 name/value pairs
 are <a
 href="http://www.blooberry.com/indexdot/html/topics/urlencoding.htm">URL-encoded</a>

Modified: trunk/thirdparty/drakma/request.lisp
===================================================================
--- trunk/thirdparty/drakma/request.lisp	2009-12-01 22:49:53 UTC (rev 4486)
+++ trunk/thirdparty/drakma/request.lisp	2009-12-14 20:26:57 UTC (rev 4487)
@@ -237,19 +237,20 @@
 PARAMETERS is an alist of name/value pairs \(the car and the cdr each
 being a string) which denotes the parameters which are added to the
 query part of the URL or \(in the case of a POST request) comprise the
-body of the request.  (But see CONTENT below.)  The name/value pairs
-are URL-encoded using the FLEXI-STREAMS external format
-EXTERNAL-FORMAT-OUT before they are sent to the server unless
-FORM-DATA is true in which case the POST request body is sent as
-`multipart/form-data' using EXTERNAL-FORMAT-OUT.  The values of the
-PARAMETERS alist can also be pathnames, open binary input streams,
-unary functions, or lists where the first element is of one of the
-former types.  These values denote files which should be sent as part
-of the request body.  If files are present in PARAMETERS, the content
-type of the request is always `multipart/form-data'.  If the value is
-a list, the part of the list behind the first element is treated as a
-plist which can be used to specify a content type and/or a filename
-for the file, i.e. such a value could look like, e.g.,
+body of the request.  (But see CONTENT below.)  The values can also be
+NIL in which case only the name \(without an equal sign) is used in
+the query string.  The name/value pairs are URL-encoded using the
+FLEXI-STREAMS external format EXTERNAL-FORMAT-OUT before they are sent
+to the server unless FORM-DATA is true in which case the POST request
+body is sent as `multipart/form-data' using EXTERNAL-FORMAT-OUT.  The
+values of the PARAMETERS alist can also be pathnames, open binary
+input streams, unary functions, or lists where the first element is of
+one of the former types.  These values denote files which should be
+sent as part of the request body.  If files are present in PARAMETERS,
+the content type of the request is always `multipart/form-data'.  If
+the value is a list, the part of the list behind the first element is
+treated as a plist which can be used to specify a content type and/or
+a filename for the file, i.e. such a value could look like, e.g.,
 \(#p\"/tmp/my_file.doc\" :content-type \"application/msword\"
 :filename \"upload.doc\").
 
@@ -406,7 +407,10 @@
       (setq proxy (list proxy 80))))
   ;; make sure we don't get :CRLF on Windows
   (let ((*default-eol-style* :lf)
-        (file-parameters-p (find-if-not #'stringp parameters :key #'cdr))
+        (file-parameters-p (find-if-not (lambda (thing)
+                                          (or (stringp thing)
+                                              (null thing)))
+                                        parameters :key #'cdr))
         parameters-used-p)
     (when (and file-parameters-p (not (eq method :post)))
       (parameter-error "Don't know how to handle parameters in ~S, as this is not a POST request."

Modified: trunk/thirdparty/drakma/util.lisp
===================================================================
--- trunk/thirdparty/drakma/util.lisp	2009-12-01 22:49:53 UTC (rev 4486)
+++ trunk/thirdparty/drakma/util.lisp	2009-12-14 20:26:57 UTC (rev 4487)
@@ -111,18 +111,19 @@
 
 (defun alist-to-url-encoded-string (alist external-format)
   "ALIST is supposed to be an alist of name/value pairs where both
-names and values are strings.  This function returns a string where
-this list is represented as for the content type
-`application/x-www-form-urlencoded', i.e. the values are URL-encoded
-using the external format EXTERNAL-FORMAT, the pairs are joined with a
-#\\& character, and each name is separated from its value with a #\\=
-character."
+names and values are strings \(or, for values, NIL).  This function
+returns a string where this list is represented as for the content
+type `application/x-www-form-urlencoded', i.e. the values are
+URL-encoded using the external format EXTERNAL-FORMAT, the pairs are
+joined with a #\\& character, and each name is separated from its
+value with a #\\= character.  If the value is NIL, no #\\= is used."
   (with-output-to-string (out)
     (loop for first = t then nil
           for (name . value) in alist
           unless first do (write-char #\& out)
-          do (format out "~A=~A"
+          do (format out "~A~:[~;=~A~]"
                       (url-encode name external-format)
+                      value
                       (url-encode value external-format)))))
 
 (defun default-port (uri)





More information about the Bknr-cvs mailing list