[drakma-devel] http-request header issue

Ross Jekel ross at sourcelabs.com
Sat Sep 29 07:00:12 UTC 2007


Hi, I'm a first time user of Drakma and I so much appreciate this library. I've been using Aserve's client functions which so far have been nothing but frustrating.

Unforunately, the first time I tried Drakma it fail for me. What I was trying to do was get the wsdl file from my localhost. The URL was something like http://localhost:1579/wsdl. The wsdl service on this box requires basic authentication for everything except getting the wsdl (go figure). The problem was that when Drakma sent the header it had a '?' in the GET request.

GET /wsdl? HTTP/1.1

Just the presence of the '?' for this server caused it to send back:

HTTP/1.0 401 Unauthorized

Well, I looked at the code in request.lisp and around line 450 and it sure looks like it should leave off the '?':

(format nil "~A~@[?~A~]"
        (or (uri-path uri) "/")
        (uri-query uri)

Trouble is, a few lines above it setf's (uri-query uri) to an empty string "" if parameters-used-p is t but parameters is nil.

  (unless parameters-used-p
    (setf (uri-query uri)
          ;; append parameters to existing query of URI
          (format nil "~@[~A~]~:*~:[~;&~]~A"
                  (uri-query uri)
                  (alist-to-url-encoded-string parameters external-format-out))))

I was able to change the unless line to:

  (unless (or parameters-used-p (not parameters))

and now the GET header is:

GET /wsdl HTTP/1.1

I didn't think this was a big enough change for a patch, but thought it might be useful. The way I wrote it might be hard to read (unless with a not...), but I was just trying it to see if it worked. 

  (when (and (not parameters-used-p) parameters)

Might read better.

Thanks,
Ross



More information about the Drakma-devel mailing list