[clouchdb-devel] create-db via a squid proxy
Nate Young
youngnh at gmail.com
Wed Jun 3 16:52:38 UTC 2009
Hi, I probably wouldn't have even noticed this, as clouchdb has been
working great for me, but at work my requests to create a database
were blowing up on me:
invalid array index 0 for "" (should be nonnegative and <0)
[Condition of type SIMPLE-TYPE-ERROR]
Restarts:
0: [RETRY] Retry SLIME interactive evaluation request.
1: [ABORT] Return to SLIME's top level.
2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "worker"
RUNNING {B56E409}>)
Backtrace:
0: (SB-IMPL::OPTIMIZED-DATA-VECTOR-REF #<unavailable argument>
#<unavailable argument>)
1: (CLOUCHDB::READ-JSON-NUMBER #<SB-IMPL::STRING-INPUT-STREAM {B5A15D1}>)
2: (JSON-TO-DOCUMENT ..)
3: (CLOUCHDB::DB-REQUEST "test_db/")[:EXTERNAL]
4: (CREATE-DB)[:EXTERNAL]
5: ((LAMBDA ()))
6: (SB-INT:SIMPLE-EVAL-IN-LEXENV (WITH-CONNECTION (:HOST
"baseball.fantasy.game-host.org" :PORT "80" :DB-NAME "test_db")
(CREATE-DB :DB-NAME "test_db" :IF-EXISTS :RECREATE)) #<NULL-LEXENV>)
7: ((LAMBDA ()))
--more--
After some digging, I found that I am behind a squid proxy and my HTTP
PUT request was being responded to with a 411 error code "Length
required". create-db results in a drakma PUT request, which doesn't
contain a "Content-Length" header.
I suspect that this is also the case for any other api calls that
result in POST or PUT requests without Content-Length headers, I
haven't searched that deep.
Adding :content-length t key parameter to the http-request call in
db-request didn't induce drakma to actually add the header for me.
Adding :content "" did, and the request succeeded.
--- clouchdb.lisp 2009-06-03 11:47:29.000000000 -0500
+++ /home/soafa-user/lisp/clouchdb.lisp 2009-06-03 11:47:50.000000000 -0500
@@ -437,7 +437,7 @@
and create a new database."
(let* ((name (if db-name-p db-name *db-name*))
(res (db-request (cat (url-encode name) "/")
- :method :put)))
+ :method :put :content "")))
(if (equal "database_already_exists" (document-property :|error| res))
(ecase if-exists
((:ignore) (list (cons :|ok| t) (cons :|ignored| t)))
It's a small change, I attached the diff.
Cheers,
Nate
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clouchdb.diff
Type: application/octet-stream
Size: 532 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/clouchdb-devel/attachments/20090603/9df2399f/attachment.obj>
More information about the clouchdb-devel
mailing list