<div dir="ltr">Peter,<div><br></div><div>thanks for the bug report.  I fixed the problem (<a href="https://github.com/edicl/drakma/commit/1973b62d969b886fc536d4ebd44cfe570308c998">https://github.com/edicl/drakma/commit/1973b62d969b886fc536d4ebd44cfe570308c998</a>) and released a new version of DRAKMA.</div>

<div><br></div><div style>-Hans</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Mar 23, 2013 at 6:59 AM, Peter Stirling <span dir="ltr"><<a href="mailto:peter@pjstirling.plus.com" target="_blank">peter@pjstirling.plus.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>Hi,<br>
      <br>
      When run on drakma 1.3 the attached program signals:<br>
      <br>
      FORM-DATA makes only sense with POST requests.<br>
         [Condition of type DRAKMA:PARAMETER-ERROR]<br>
      <br>
      Restarts:<br>
       0: [ABORT] Abort compilation.<br>
       1: [*ABORT] Return to SLIME's top level.<br>
       2: [ABORT] Abort thread (#<THREAD "worker" RUNNING
      {1004D888A3}>)<br>
      <br>
      Backtrace:<br>
        0: (DRAKMA:PARAMETER-ERROR "FORM-DATA makes only sense with POST
      requests.")<br>
        1: (DRAKMA:HTTP-REQUEST #<PURI:URI
      <a href="http://localhost:8181/cookie-check.php" target="_blank">http://localhost:8181/cookie-check.php</a>> :METHOD :GET :REDIRECT
      4 :STREAM NIL :ADDITIONAL-HEADERS NIL :PARAMETERS (("theusername"
      . #1="dummy") ("thepassword" . #1#)) :P..<br>
        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 ..<br>
        3: (DRAKMA:HTTP-REQUEST #<PURI:URI
      <a href="http://localhost:8181/login.php" target="_blank">http://localhost:8181/login.php</a>> :COOKIE-JAR
      #<DRAKMA:COOKIE-JAR (with 0 cookies) {1004E26563}> :METHOD
      :POST :FORM-DATA T :PARAMETERS (("theusername" . #1="dummy") ("t..<br>
        4: (POST-REQUEST)<br>
      <br>
      On drakma 1.2.9 you get the output:<br>
      <br>
      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; <a href="http://weitz.de/drakma/" target="_blank">http://weitz.de/drakma/</a>)"<br>
      reply is <html><head><title>302 Moved
      Temporarily</title></head><body><h1>Moved
      Temporarily</h1>The document has moved <a
      href='<a href="http://localhost:8181/cookie-check.php" target="_blank">http://localhost:8181/cookie-check.php</a>'>here</a><p><hr><address><a
      href='<a href="http://weitz.de/hunchentoot/" target="_blank">http://weitz.de/hunchentoot/</a>'>Hunchentoot
      1.2.14</a> <a href='<a href="http://www.sbcl.org/" target="_blank">http://www.sbcl.org/</a>'>(SBCL
      1.1.5.15-0892423)</a> at
      localhost:8181</address></p></body></html><div><div class="h5"><br>
      <br>
      <br>
      On 22/03/13 16:21, Hans Hübner wrote:<br>
    </div></div></div><div><div class="h5">
    <blockquote type="cite">
      <div dir="ltr">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.
        <div>
          <br>
        </div>
        <div>-Hans</div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Fri, Mar 22, 2013 at 5:55 PM, <span dir="ltr"><<a href="mailto:rm@seid-online.de" target="_blank">rm@seid-online.de</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div>On Fri, Mar 22, 2013 at 12:57:15PM +0000,
              Peter Stirling wrote:<br>
              > I was getting this error too, I reverted to the
              previous version of cl+ssl<br>
              > in quicklisp by putting it in the local-projects
              directory.<br>
              ><br>
              > I've been meaning to report another problem I've had
              with the new version<br>
              > of drakma, it seems that when I POST login details to
              a site that I'm using<br>
              > it replies with a redirect,<br>
              <br>
            </div>
            How is the site redirecting? What's the HTTP status code
            they use?<br>
            <div><br>
              > and then drakma tries to POST the login details<br>
              > to the redirected page rather than accessing it with
              a GET. I'll try and<br>
              > make a test case sometime this weekend.<br>
              <br>
            </div>
            Depending on the status code, that's actually valid
            behaviour.<br>
            (see: <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2" target="_blank">http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2</a>)<br>
            <br>
             HTH Ralf Mattes<br>
            <div>
              <div><br>
                > On 21/03/13 21:41, Peter Kuchta wrote:<br>
                >> Hi everybody,<br>
                >><br>
                >> I'm trying to POST some JSON data to a web
                service:<br>
                >><br>
                >>         (ql:quickload :st-json)<br>
                >>         (ql:quickload :cl-json)<br>
                >>         (ql:quickload :drakma)<br>
                >><br>
                >>         (defvar *rc* (merge-pathnames
                (user-homedir-pathname) ".apirc"))<br>
                >><br>
                >>         (defvar *user*<br>
                >>           (with-open-file (s *rc*)<br>
                >>             (st-json:read-json s)))<br>
                >><br>
                >>         (defvar api-url (st-json:getjso "url"
                *user*))<br>
                >>         (defvar api-key (st-json:getjso "key"
                *user*))<br>
                >>         (defvar api-email (st-json:getjso
                "email" *user*))<br>
                >><br>
                >>         (setf drakma:*header-stream*
                *standard-output*)<br>
                >><br>
                >>         (defvar *req* '(("dataset" . "tigge")<br>
                >>                   ("step"    . "24")<br>
                >>                   ("date"    . "20071001")<br>
                >>                   ("time"    . "00")<br>
                >>                   ("origin"  . "all")))<br>
                >><br>
                >>         (format t "json:~S~%"
                (json:encode-json-to-string *req*))<br>
                >><br>
                >>         (defun retrieve (api request)<br>
                >>           (let* ((cookie-jar (make-instance
                'drakma:cookie-jar))<br>
                >>                  (extra-headers (list (cons
                "From" api-email)<br>
                >>                                       (cons
                "X-API-KEY" api-key)))<br>
                >>                  (url (concatenate 'string
                api-url api "/requests"))<br>
                >>                  (stream (drakma:http-request
                url<br>
                >>                              
                 :additional-headers extra-headers<br>
                >>                                :accept
                "application/json"<br>
                >>                                :method :post<br>
                >>                                :content-type
                "application/json"<br>
                >>                              
                 :external-format-out :utf-8<br>
                >>                              
                 :external-format-in :utf-8<br>
                >>                                :redirect 100<br>
                >>                                :cookie-jar
                cookie-jar<br>
                >>                                :content
                (json:encode-json-to-string<br>
                >> request)<br>
                >>                                :want-stream
                t)))<br>
                >>               (st-json:read-json stream)))<br>
                >><br>
                >>      (retrieve "/datasets/tigge" *req*)<br>
                >><br>
                >> Unfortunately, I get an error, although the
                data seems to be encoded OK to<br>
                >> JSON and the headers generated by drakma too, I
                think. Apparently<br>
                >> something is wrong with the :content (the list
                of integers in the errors<br>
                >> message is just the list of ASCII codes of the
                JSON encoded data).<br>
                >><br>
                >>
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\"}"<br>


                >><br>
                >>     POST /v1/datasets/tigge/requests HTTP/1.1<br>
              </div>
            </div>
            >>     Host: <a href="http://api.service.int" target="_blank">api.service.int</a>
            <<a href="http://api.service.int" target="_blank">http://api.service.int</a>><br>
            <div>>>     User-Agent: Drakma/1.3.0 (SBCL
              1.1.5; Darwin; 12.2.0;<br>
              >> <a href="http://weitz.de/drakma/" target="_blank">http://weitz.de/drakma/</a>)<br>
              >>     Accept: application/json<br>
              >>     Connection: close<br>
            </div>
            >>     From: <a href="mailto:me@gmail.com" target="_blank">me@gmail.com</a> <mailto:<a href="mailto:me@gmail.com" target="_blank">me@gmail.com</a>><br>
            <div>
              <div>>>     X-API-KEY:
                19a0edb6d8d8dda1e6a3b21223e4f86a<br>
                >>     Content-Type: application/json<br>
                >>     Content-Length: 193<br>
                >><br>
                >><br>
                >>     debugger invoked on a SIMPLE-TYPE-ERROR:<br>
                >>       The value of CL+SSL::THING is #(123 34
                100 97 116 97 115 101 116 34<br>
                >> 58 34<br>
                >>                                   ...), which
                is not of type (SIMPLE-ARRAY<br>
                >>     (UNSIGNED-BYTE 8)<br>
                >>     (*)).<br>
                >><br>
                >> Any idea what's wrong with this code? Many
                thanks in advance.<br>
                >><br>
                >> Best regards,<br>
                >> Piotr<br>
                >><br>
                >><br>
                >> _______________________________________________<br>
                >> drakma-devel mailing list<br>
                >> <a href="mailto:drakma-devel@common-lisp.net" target="_blank">drakma-devel@common-lisp.net</a><br>
                >> <a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel</a><br>
                ><br>
                <br>
                > _______________________________________________<br>
                > drakma-devel mailing list<br>
                > <a href="mailto:drakma-devel@common-lisp.net" target="_blank">drakma-devel@common-lisp.net</a><br>
                > <a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel</a><br>
                <br>
                <br>
                _______________________________________________<br>
                drakma-devel mailing list<br>
                <a href="mailto:drakma-devel@common-lisp.net" target="_blank">drakma-devel@common-lisp.net</a><br>
                <a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel</a><br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
drakma-devel mailing list
<a href="mailto:drakma-devel@common-lisp.net" target="_blank">drakma-devel@common-lisp.net</a>
<a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
drakma-devel mailing list<br>
<a href="mailto:drakma-devel@common-lisp.net">drakma-devel@common-lisp.net</a><br>
<a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel</a><br>
<br></blockquote></div><br></div>