Hi,
When run on drakma 1.3 the attached program signals:
FORM-DATA makes only sense with POST requests. [Condition of type DRAKMA:PARAMETER-ERROR]
Restarts: 0: [ABORT] Abort compilation. 1: [*ABORT] Return to SLIME's top level. 2: [ABORT] Abort thread (#<THREAD "worker" RUNNING {1004D888A3}>)
Backtrace: 0: (DRAKMA:PARAMETER-ERROR "FORM-DATA makes only sense with POST requests.") 1: (DRAKMA:HTTP-REQUEST #<PURI:URI http://localhost:8181/cookie-check.php%3E :METHOD :GET :REDIRECT 4 :STREAM NIL :ADDITIONAL-HEADERS NIL :PARAMETERS (("theusername" . #1="dummy") ("thepassword" . #1#)) :P.. 2: ((LABELS DRAKMA::FINISH-REQUEST :IN DRAKMA:HTTP-REQUEST) #(45 45 45 45 45 45 45 45 45 45 45 45 54 109 108 70 48 57 66 116 83 122 49 79 110 73 48 54 71 78 50 50 99 113 69 57 106 66 79 105 56 76 50 111 .. 3: (DRAKMA:HTTP-REQUEST #<PURI:URI http://localhost:8181/login.php%3E :COOKIE-JAR #<DRAKMA:COOKIE-JAR (with 0 cookies) {1004E26563}> :METHOD :POST :FORM-DATA T :PARAMETERS (("theusername" . #1="dummy") ("t.. 4: (POST-REQUEST)
On drakma 1.2.9 you get the output:
127.0.0.1 - [2013-03-23 05:47:08] "POST /login.php HTTP/1.1" 302 349 "-" "Drakma/1.2.9 (SBCL 1.1.5.15-0892423; Linux; 3.5.0-26-generic; http://weitz.de/drakma/)" reply is <html><head><title>302 Moved Temporarily</title></head><body><h1>Moved Temporarily</h1>The document has moved <a href='http://localhost:8181/cookie-check.php'>here</a><p><hr><address><a href='http://weitz.de/hunchentoot/'>Hunchentoot 1.2.14</a> <a href='http://www.sbcl.org/'>(SBCL 1.1.5.15-0892423)</a> at localhost:8181</address></p></body></html>
On 22/03/13 16:21, Hans Hübner wrote:
Drakma's behavior with respect to redirects has recently changed so that it is standard compliant. I would like to keep it that way, but if this is a hurdle that can't be worked around, I am open to suggestions to change it again.
-Hans
On Fri, Mar 22, 2013 at 5:55 PM, <rm@seid-online.de mailto:rm@seid-online.de> wrote:
On Fri, Mar 22, 2013 at 12:57:15PM +0000, Peter Stirling wrote: > I was getting this error too, I reverted to the previous version of cl+ssl > in quicklisp by putting it in the local-projects directory. > > I've been meaning to report another problem I've had with the new version > of drakma, it seems that when I POST login details to a site that I'm using > it replies with a redirect, How is the site redirecting? What's the HTTP status code they use? > and then drakma tries to POST the login details > to the redirected page rather than accessing it with a GET. I'll try and > make a test case sometime this weekend. Depending on the status code, that's actually valid behaviour. (see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2) HTH Ralf Mattes > On 21/03/13 21:41, Peter Kuchta wrote: >> Hi everybody, >> >> I'm trying to POST some JSON data to a web service: >> >> (ql:quickload :st-json) >> (ql:quickload :cl-json) >> (ql:quickload :drakma) >> >> (defvar *rc* (merge-pathnames (user-homedir-pathname) ".apirc")) >> >> (defvar *user* >> (with-open-file (s *rc*) >> (st-json:read-json s))) >> >> (defvar api-url (st-json:getjso "url" *user*)) >> (defvar api-key (st-json:getjso "key" *user*)) >> (defvar api-email (st-json:getjso "email" *user*)) >> >> (setf drakma:*header-stream* *standard-output*) >> >> (defvar *req* '(("dataset" . "tigge") >> ("step" . "24") >> ("date" . "20071001") >> ("time" . "00") >> ("origin" . "all"))) >> >> (format t "json:~S~%" (json:encode-json-to-string *req*)) >> >> (defun retrieve (api request) >> (let* ((cookie-jar (make-instance 'drakma:cookie-jar)) >> (extra-headers (list (cons "From" api-email) >> (cons "X-API-KEY" api-key))) >> (url (concatenate 'string api-url api "/requests")) >> (stream (drakma:http-request url >> :additional-headers extra-headers >> :accept "application/json" >> :method :post >> :content-type "application/json" >> :external-format-out :utf-8 >> :external-format-in :utf-8 >> :redirect 100 >> :cookie-jar cookie-jar >> :content (json:encode-json-to-string >> request) >> :want-stream t))) >> (st-json:read-json stream))) >> >> (retrieve "/datasets/tigge" *req*) >> >> Unfortunately, I get an error, although the data seems to be encoded OK to >> JSON and the headers generated by drakma too, I think. Apparently >> something is wrong with the :content (the list of integers in the errors >> message is just the list of ASCII codes of the JSON encoded data). >> >> json:"{\"dataset\":\"tigge\",\"step\":\"24\",\"number\":\"all\",\"levtype\":\"sl\",\"date\":\"20071001\",\"time\":\"00\",\"origin\":\"all\",\"type\":\"pf\",\"param\":\"tp\",\"area\":\"70\\/-130\\/30\\/-60\",\"grid\":\"2\\/2\",\"target\":\"data.grib\"}" >> >> POST /v1/datasets/tigge/requests HTTP/1.1 >> Host: api.service.int <http://api.service.int> <http://api.service.int> >> User-Agent: Drakma/1.3.0 (SBCL 1.1.5; Darwin; 12.2.0; >> http://weitz.de/drakma/) >> Accept: application/json >> Connection: close >> From: me@gmail.com <mailto:me@gmail.com> <mailto:me@gmail.com <mailto:me@gmail.com>> >> X-API-KEY: 19a0edb6d8d8dda1e6a3b21223e4f86a >> Content-Type: application/json >> Content-Length: 193 >> >> >> debugger invoked on a SIMPLE-TYPE-ERROR: >> The value of CL+SSL::THING is #(123 34 100 97 116 97 115 101 116 34 >> 58 34 >> ...), which is not of type (SIMPLE-ARRAY >> (UNSIGNED-BYTE 8) >> (*)). >> >> Any idea what's wrong with this code? Many thanks in advance. >> >> Best regards, >> Piotr >> >> >> _______________________________________________ >> drakma-devel mailing list >> drakma-devel@common-lisp.net <mailto:drakma-devel@common-lisp.net> >> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel > > _______________________________________________ > drakma-devel mailing list > drakma-devel@common-lisp.net <mailto:drakma-devel@common-lisp.net> > http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel _______________________________________________ drakma-devel mailing list drakma-devel@common-lisp.net <mailto:drakma-devel@common-lisp.net> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel
drakma-devel mailing list drakma-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel