Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 27435 invoked from network); 13 Jan 2011 15:54:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Jan 2011 15:54:03 -0000 Received: (qmail 33060 invoked by uid 500); 13 Jan 2011 15:54:02 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 33014 invoked by uid 500); 13 Jan 2011 15:53:59 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 33006 invoked by uid 99); 13 Jan 2011 15:53:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Jan 2011 15:53:59 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bchesneau@gmail.com designates 209.85.210.180 as permitted sender) Received: from [209.85.210.180] (HELO mail-iy0-f180.google.com) (209.85.210.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Jan 2011 15:53:51 +0000 Received: by iyj21 with SMTP id 21so1832992iyj.11 for ; Thu, 13 Jan 2011 07:53:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=Sa2gXnJ/xAiXmM7Deg3xnCp8p6aOrR2FA+0pmFiZlxI=; b=TePgPOsUz5KomXkrs8JLC68lX/b6dQXEe8o8J6Lf2g+kb6+zUucEWdrlIUAAPQXhgG LY45a5lhVa3vsS77CoDwrjESdixiJnxA8Pn4LGqsLTJIvB6RkLsk8ucQOS3L9ZFuqcuF hs1JWhkabx9BrB+ehoeqptl1ZUjQ+N1ED3kck= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=k7XtFm66htU20x3KsYRboVbXyGhY7OlxGa6rT9b38Y2lqXEKDPC/GBYWFsF6qFIxdm twyTgOREdCCggVSIgx3cq3B9tv6Am1lifj5LvX6TfPfoDv9b7cUYOP26u6nVusNmimON Lp92gCujIIAnVblj95GOODY8M84+nH+2aFINU= MIME-Version: 1.0 Received: by 10.231.15.202 with SMTP id l10mr2578576iba.19.1294934009591; Thu, 13 Jan 2011 07:53:29 -0800 (PST) Received: by 10.231.32.193 with HTTP; Thu, 13 Jan 2011 07:53:29 -0800 (PST) In-Reply-To: References: Date: Thu, 13 Jan 2011 16:53:29 +0100 Message-ID: Subject: Re: Strange issue with VHosts and rewrites... From: Benoit Chesneau To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Jan 13, 2011 at 4:17 PM, Janez =C5=A0tupar = wrote: > Beno=C3=AEt, I did what you proposed and it behaves exactly as before > > Ok i did some testing and this is what I figured out. > > This is my testing setup: I created a new database (test) that doesn't us= e > any VHost rules. > > Inside it I created a design document that only has rewrites field. I wil= l > present test results exactly as per configuration I used. > > I always sent the same document contained in file "example" - namely: > { > =C2=A0 =C2=A0"type": "comment" > } > > Below are the test results: > -------------------------------------------------------------------------= --------------------------- > ## Test 1: > # rewrites config: > [ > =C2=A0 { > =C2=A0 =C2=A0 =C2=A0 "to": "../..", > =C2=A0 =C2=A0 =C2=A0 "from": ":db" > =C2=A0 } > ] > > # Executed command 1.1: > $ curl =C2=A0-d @example -H "Content-type:application/json" -e > http://localhost:5984/test =C2=A0http://localhost:5984/test/ > {"ok":true,"id":"ce8b504d63666c9257cc07537c00aa70","rev":"1-505a221d0aef5= d664f29d6afdae01293"} > > # Comment: expected result - everything is fine. > > > > # Executed command 1.2: > $ curl -X PUT =C2=A0-d @example -H "Content-type:application/json" > http://localhost:5984/test/_design/test/_rewrite/test/randomid324324 > {"error":"not_found","reason":"missing"} > > # Comment: result expected since there is no ID parameter passed through = - > due to the rewrite rule > > #LOG: > [Mon, 10 Jan 2011 21:42:17 GMT] [debug] [<0.8844.3>] 'PUT' > /test/_design/test/_rewrite/test/randomid324324 {1,1} > Headers: [{'Accept',"*/*"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Length',"23"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Type',"application/json"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Host',"localhost:5984"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'User-Agent',"curl/7.21.0 (i686-pc-lin= ux-gnu) libcurl/7.21.0 > OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18"}] > > [Mon, 10 Jan 2011 21:42:17 GMT] [debug] [<0.8844.3>] OAuth Params: [] > > [Mon, 10 Jan 2011 21:42:17 GMT] [debug] [<0.8844.3>] Minor error in HTTP > request: not_found > > [Mon, 10 Jan 2011 21:42:17 GMT] [debug] [<0.8844.3>] Stacktrace: > [{couch_httpd_rewrite,handle_rewrite_req,3}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,do_db_req,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd,handle_request_int= ,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {mochiweb_http,headers,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {proc_lib,init_p_do_apply,3}] > > [Mon, 10 Jan 2011 21:42:17 GMT] [info] [<0.8844.3>] 127.0.0.1 - - 'PUT' > /test/_design/test/_rewrite/test/randomid324324 404 > > [Mon, 10 Jan 2011 21:42:17 GMT] [debug] [<0.8844.3>] httpd 404 error > response: > =C2=A0{"error":"not_found","reason":"missing"} > > > > > # Executed command 1.3: > $curl =C2=A0-d @example -H "Content-type:application/json" -e > http://localhost:5984/test > http://localhost:5984/test/_design/test/_rewrite/test/ > {"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > # Comment: Rewrite is wrong - also peculiar it won't take application/jso= n > content type. > > # LOG: > [Mon, 10 Jan 2011 21:51:55 GMT] [debug] [<0.9453.3>] 'POST' > /test/_design/test/_rewrite/test/ {1,1} > Headers: [{'Accept',"*/*"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Length',"23"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Type',"application/json"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Host',"localhost:5984"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Referer',"http://localhost:5984/test"= }, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'User-Agent',"curl/7.21.0 (i686-pc-lin= ux-gnu) libcurl/7.21.0 > OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18"}] > > [Mon, 10 Jan 2011 21:51:55 GMT] [debug] [<0.9453.3>] OAuth Params: [] > > [Mon, 10 Jan 2011 21:51:55 GMT] [debug] [<0.9453.3>] rewrite to > "/test/_design/..?db=3Dtest" > > > [Mon, 10 Jan 2011 21:51:55 GMT] [debug] [<0.9453.3>] 'POST' > /test/_design/..?db=3Dtest {1,1} > Headers: [{'Accept',"*/*"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Length',"23"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Type',"application/json"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Host',"localhost:5984"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Referer',"http://localhost:5984/test"= }, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'User-Agent',"curl/7.21.0 (i686-pc-lin= ux-gnu) libcurl/7.21.0 > OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18"}] > > [Mon, 10 Jan 2011 21:51:55 GMT] [debug] [<0.9453.3>] OAuth Params: > [{"db","test"}] > > [Mon, 10 Jan 2011 21:51:55 GMT] [debug] [<0.9453.3>] Minor error in HTTP > request: {bad_ctype, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Content-Type must be multipart/form= -data"} > > [Mon, 10 Jan 2011 21:51:55 GMT] [debug] [<0.9453.3>] Stacktrace: > [{couch_httpd,validate_ctype,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,db_doc_req,3}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,do_db_req,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd,handle_request_int= ,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,do_db_req,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd,handle_request_int= ,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {mochiweb_http,headers,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {proc_lib,init_p_do_apply,3}] > > [Mon, 10 Jan 2011 21:51:55 GMT] [info] [<0.9453.3>] 127.0.0.1 - - 'POST' > /test/_design/..?db=3Dtest 415 > > [Mon, 10 Jan 2011 21:51:55 GMT] [debug] [<0.9453.3>] httpd 415 error > response: > =C2=A0{"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > > > # Executed command 1.4: > $ curl =C2=A0-d @example -H "Content-type:application/json" -e > http://localhost:5984/test =C2=A0http://localhost:5984/test/randomid32420 > {"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > # Comment: I did this one just because - and I noticed that when you post > with and ID - it wont accept JSON content type > > # LOG: > [Mon, 10 Jan 2011 21:54:23 GMT] [debug] [<0.9490.3>] 'POST' > /test/randomid32420 {1,1} > Headers: [{'Accept',"*/*"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Length',"23"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Type',"application/json"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Host',"localhost:5984"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Referer',"http://localhost:5984/test"= }, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'User-Agent',"curl/7.21.0 (i686-pc-lin= ux-gnu) libcurl/7.21.0 > OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18"}] > > [Mon, 10 Jan 2011 21:54:23 GMT] [debug] [<0.9490.3>] OAuth Params: [] > > [Mon, 10 Jan 2011 21:54:23 GMT] [debug] [<0.9490.3>] Minor error in HTTP > request: {bad_ctype, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Content-Type must be multipart/form= -data"} > > [Mon, 10 Jan 2011 21:54:23 GMT] [debug] [<0.9490.3>] Stacktrace: > [{couch_httpd,validate_ctype,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,db_doc_req,3}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,do_db_req,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd,handle_request_int= ,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {mochiweb_http,headers,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {proc_lib,init_p_do_apply,3}] > > [Mon, 10 Jan 2011 21:54:23 GMT] [info] [<0.9490.3>] 127.0.0.1 - - 'POST' > /test/randomid32420 415 > > [Mon, 10 Jan 2011 21:54:23 GMT] [debug] [<0.9490.3>] httpd 415 error > response: > =C2=A0{"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > > > -------------------------------------------------------------------------= --------------------------- > > > ## Test 2: > > # Rewrites config: > [ > =C2=A0 { > =C2=A0 =C2=A0 =C2=A0 "to": "../../*", > =C2=A0 =C2=A0 =C2=A0 "from": ":db/*" > =C2=A0 } > ] > > # Executed command 2.1: > $ curl =C2=A0-d @example -H "Content-type:application/json" -e > http://localhost:5984/test =C2=A0http://localhost:5984/test/ > {"ok":true,"id":"ce8b504d63666c9257cc07537c00af99","rev":"1-505a221d0aef5= d664f29d6afdae01293"} > > # Comment: OK, everything is fine > > > > #Executed command 2.2: > $ curl -X PUT =C2=A0-d @example -H "Content-type:application/json" > http://localhost:5984/test/_design/test/_rewrite/test/randomid3125 > {"ok":true,"id":"randomid3125","rev":"1-505a221d0aef5d664f29d6afdae01293"= } > > # Comment: OK, everything is fine - since now rewrite rule appropriately > handles the ID. > > > #Executed command 2.3: > $ curl =C2=A0-d @example -H "Content-type:application/json" -e > http://localhost:5984/test > http://localhost:5984/test/_design/test/_rewrite/test/ > {"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > # Comment: Routing and content type are wrong (routing in PUT request - > command 2.2 was done right!) > > # LOG: > [Mon, 10 Jan 2011 22:06:17 GMT] [debug] [<0.10262.3>] 'POST' > /test/_design/test/_rewrite/test/ {1,1} > Headers: [{'Accept',"*/*"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Length',"23"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Type',"application/json"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Host',"localhost:5984"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Referer',"http://localhost:5984/test"= }, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'User-Agent',"curl/7.21.0 (i686-pc-lin= ux-gnu) libcurl/7.21.0 > OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18"}] > > [Mon, 10 Jan 2011 22:06:17 GMT] [debug] [<0.10262.3>] OAuth Params: [] > > [Mon, 10 Jan 2011 22:06:17 GMT] [debug] [<0.10262.3>] rewrite to > "/test/_design/..?db=3Dtest" > > > [Mon, 10 Jan 2011 22:06:17 GMT] [debug] [<0.10262.3>] 'POST' > /test/_design/..?db=3Dtest {1,1} > Headers: [{'Accept',"*/*"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Length',"23"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Type',"application/json"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Host',"localhost:5984"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Referer',"http://localhost:5984/test"= }, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'User-Agent',"curl/7.21.0 (i686-pc-lin= ux-gnu) libcurl/7.21.0 > OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18"}] > > [Mon, 10 Jan 2011 22:06:17 GMT] [debug] [<0.10262.3>] OAuth Params: > [{"db","test"}] > > [Mon, 10 Jan 2011 22:06:17 GMT] [debug] [<0.10262.3>] Minor error in HTTP > request: {bad_ctype, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Content-Type must be multipart/form= -data"} > > [Mon, 10 Jan 2011 22:06:17 GMT] [debug] [<0.10262.3>] Stacktrace: > [{couch_httpd,validate_ctype,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,db_doc_req,3}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,do_db_req,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd,handle_request_int= ,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,do_db_req,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd,handle_request_int= ,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {mochiweb_http,headers,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {proc_lib,init_p_do_apply,3}] > > [Mon, 10 Jan 2011 22:06:17 GMT] [info] [<0.10262.3>] 127.0.0.1 - - 'POST' > /test/_design/..?db=3Dtest 415 > > [Mon, 10 Jan 2011 22:06:17 GMT] [debug] [<0.10262.3>] httpd 415 error > response: > =C2=A0{"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > > #Executed command 2.4: > $ curl =C2=A0-d @example -H "Content-type:application/json" -e > http://localhost:5984/test =C2=A0http://localhost:5984/test/randomid32843 > {"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > #Comment: No routing information in log, got Cotent type error. > > #LOG: > [Mon, 10 Jan 2011 22:11:53 GMT] [debug] [<0.10377.3>] 'POST' > /test/randomid32843 {1,1} > Headers: [{'Accept',"*/*"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Length',"23"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Type',"application/json"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Host',"localhost:5984"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Referer',"http://localhost:5984/test"= }, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'User-Agent',"curl/7.21.0 (i686-pc-lin= ux-gnu) libcurl/7.21.0 > OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18"}] > > [Mon, 10 Jan 2011 22:11:53 GMT] [debug] [<0.10377.3>] OAuth Params: [] > > [Mon, 10 Jan 2011 22:11:53 GMT] [debug] [<0.10377.3>] Minor error in HTTP > request: {bad_ctype, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Content-Type must be multipart/form= -data"} > > [Mon, 10 Jan 2011 22:11:53 GMT] [debug] [<0.10377.3>] Stacktrace: > [{couch_httpd,validate_ctype,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,db_doc_req,3}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,do_db_req,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd,handle_request_int= ,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {mochiweb_http,headers,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {proc_lib,init_p_do_apply,3}] > > [Mon, 10 Jan 2011 22:11:53 GMT] [info] [<0.10377.3>] 127.0.0.1 - - 'POST' > /test/randomid32843 415 > > [Mon, 10 Jan 2011 22:11:53 GMT] [debug] [<0.10377.3>] httpd 415 error > response: > =C2=A0{"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > -------------------------------------------------------------------------= --------------------------- > > > ## Test 3: > > # Rewrites config: > [ > =C2=A0 { > =C2=A0 =C2=A0 =C2=A0 "to": "../../*", > =C2=A0 =C2=A0 =C2=A0 "from": ":db/*" > =C2=A0 }, > =C2=A0 { > =C2=A0 =C2=A0 =C2=A0 "to": "../..", > =C2=A0 =C2=A0 =C2=A0 "from": ":db" > =C2=A0 } > ] > > > # Executed command 3.1: > $ curl =C2=A0-d @example -H "Content-type:application/json" -e > http://localhost:5984/test =C2=A0http://localhost:5984/test/ > {"ok":true,"id":"ce8b504d63666c9257cc07537c00bbe3","rev":"1-505a221d0aef5= d664f29d6afdae01293"} > > # Comment: OK! works as expected > > > > #Executed command 3.2: > $ curl -X PUT =C2=A0-d @example -H "Content-type:application/json" > http://localhost:5984/test/_design/test/_rewrite/test/randomid43242 > {"ok":true,"id":"randomid43242","rev":"1-505a221d0aef5d664f29d6afdae01293= "} > > # Comment: OK! works as expected > > > #Executed command 3.3: > $ curl =C2=A0-d @example -H "Content-type:application/json" -e > http://localhost:5984/test > http://localhost:5984/test/_design/test/_rewrite/test/ > {"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > # Comment: Rewrite issue and content type issue > > # LOG: > [Mon, 10 Jan 2011 22:19:55 GMT] [debug] [<0.11199.3>] 'POST' > /test/_design/test/_rewrite/test/ {1,1} > Headers: [{'Accept',"*/*"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Length',"23"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Type',"application/json"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Host',"localhost:5984"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Referer',"http://localhost:5984/test"= }, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'User-Agent',"curl/7.21.0 (i686-pc-lin= ux-gnu) libcurl/7.21.0 > OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18"}] > > [Mon, 10 Jan 2011 22:19:55 GMT] [debug] [<0.11199.3>] OAuth Params: [] > > [Mon, 10 Jan 2011 22:19:55 GMT] [debug] [<0.11199.3>] rewrite to > "/test/_design/..?db=3Dtest" > > > [Mon, 10 Jan 2011 22:19:55 GMT] [debug] [<0.11199.3>] 'POST' > /test/_design/..?db=3Dtest {1,1} > Headers: [{'Accept',"*/*"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Length',"23"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Type',"application/json"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Host',"localhost:5984"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Referer',"http://localhost:5984/test"= }, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'User-Agent',"curl/7.21.0 (i686-pc-lin= ux-gnu) libcurl/7.21.0 > OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18"}] > > [Mon, 10 Jan 2011 22:19:55 GMT] [debug] [<0.11199.3>] OAuth Params: > [{"db","test"}] > > [Mon, 10 Jan 2011 22:19:55 GMT] [debug] [<0.11199.3>] Minor error in HTTP > request: {bad_ctype, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Content-Type must be multipart/form= -data"} > > [Mon, 10 Jan 2011 22:19:55 GMT] [debug] [<0.11199.3>] Stacktrace: > [{couch_httpd,validate_ctype,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,db_doc_req,3}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,do_db_req,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd,handle_request_int= ,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,do_db_req,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd,handle_request_int= ,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {mochiweb_http,headers,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {proc_lib,init_p_do_apply,3}] > > [Mon, 10 Jan 2011 22:19:55 GMT] [info] [<0.11199.3>] 127.0.0.1 - - 'POST' > /test/_design/..?db=3Dtest 415 > > [Mon, 10 Jan 2011 22:19:55 GMT] [debug] [<0.11199.3>] httpd 415 error > response: > =C2=A0{"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > > #Executed command 3.4: > $ =C2=A0curl =C2=A0-d @example -H "Content-type:application/json" -e > http://localhost:5984/test =C2=A0http://localhost:5984/test/randomid43243= 2 > {"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > #Comment: Obviously no rewrite issue, however content type problem is the= re > > #LOG: > [Mon, 10 Jan 2011 22:21:24 GMT] [debug] [<0.11220.3>] 'POST' > /test/randomid432432 {1,1} > Headers: [{'Accept',"*/*"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Length',"23"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Content-Type',"application/json"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Host',"localhost:5984"}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'Referer',"http://localhost:5984/test"= }, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{'User-Agent',"curl/7.21.0 (i686-pc-lin= ux-gnu) libcurl/7.21.0 > OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18"}] > > [Mon, 10 Jan 2011 22:21:24 GMT] [debug] [<0.11220.3>] OAuth Params: [] > > [Mon, 10 Jan 2011 22:21:24 GMT] [debug] [<0.11220.3>] Minor error in HTTP > request: {bad_ctype, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Content-Type must be multipart/form= -data"} > > [Mon, 10 Jan 2011 22:21:24 GMT] [debug] [<0.11220.3>] Stacktrace: > [{couch_httpd,validate_ctype,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,db_doc_req,3}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd_db,do_db_req,2}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {couch_httpd,handle_request_int= ,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {mochiweb_http,headers,5}, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {proc_lib,init_p_do_apply,3}] > > [Mon, 10 Jan 2011 22:21:24 GMT] [info] [<0.11220.3>] 127.0.0.1 - - 'POST' > /test/randomid432432 415 > > [Mon, 10 Jan 2011 22:21:24 GMT] [debug] [<0.11220.3>] httpd 415 error > response: > =C2=A0{"error":"bad_content_type","reason":"Content-Type must be > multipart/form-data"} > > > > Apparently these are two different issues. > > First handling of rewrites for POST requests and the second is the proble= m > with Content types? > > Also I would be extremely happy to find out what are more exact rules for > pattern matching? I have found this site ( > http://caolanmcmahon.com/on_designs_undocumented.html) which provides som= e > answers. I have also read somewhere that rewriting is basically Erlang > pattern matching ... so should I read up more about the topic in Erlang > documentation? > > There is also a question I have that wasn't answered anywhere - is it > possible for multiple rewrites to apply to single request? If so what is = the > precedence? If not - what is the precedence in that case. > > Thank you for any response. > > Kind regards, -Janez > > On Thu, Jan 13, 2011 at 8:21 AM, Benoit Chesneau wro= te: > >> did you try to add: >> >> { >> >> "from": ":db", >> "to": "../.." >> } >> >> ? >> >> - beno=C3=AEt >> >> On Mon, Jan 10, 2011 at 6:21 PM, Janez =C5=A0tupar >> wrote: >> > Here is the problem I'm currently dabbling around with Sofa (got it fr= om >> > jchrisa's Github)... To this end I'm reverse engineering it and trying= to >> > get it work in a following scenario: >> > >> > The database is hidden behind following VHost: sofa.mycouch =C2=A0-> >> > /sofa/_design/sofa/_rewrite >> > >> > Since I wanted to improve the appearance of the URL's I also did some >> > modifications to the rewrites, my current configuration is as follows: >> > >> > [ >> > =C2=A0 { >> > =C2=A0 =C2=A0 =C2=A0 "to": "_list/index/recent-posts", >> > =C2=A0 =C2=A0 =C2=A0 "from": "blog/", >> > =C2=A0 =C2=A0 =C2=A0 "query": { >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "limit": 10, >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "descending": true >> > =C2=A0 =C2=A0 =C2=A0 } >> > =C2=A0 }, >> > =C2=A0 { >> > =C2=A0 =C2=A0 =C2=A0 "to": "_list/:listname/*", >> > =C2=A0 =C2=A0 =C2=A0 "from": "list/:listname/*", >> > =C2=A0 =C2=A0 =C2=A0 "query": { >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "limit": 10, >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "descending": true >> > =C2=A0 =C2=A0 =C2=A0 } >> > =C2=A0 }, >> > =C2=A0 { >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0"to" : "_show/:showname/*", >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0"from" : "show/:showname/*" >> > =C2=A0 }, >> > =C2=A0 { >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 "to" : "_update/:updatename/*", >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 "from" : "update/:updatename/*" >> > =C2=A0 }, >> > =C2=A0 { >> > =C2=A0 =C2=A0 =C2=A0 "to": "_list/index/recent-posts", >> > =C2=A0 =C2=A0 =C2=A0 "from": "", >> > =C2=A0 =C2=A0 =C2=A0 "query": { >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "limit": 10, >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "descending": true >> > =C2=A0 =C2=A0 =C2=A0 } >> > =C2=A0 }, >> > =C2=A0 { >> > =C2=A0 =C2=A0 =C2=A0 "to": "script/*", >> > =C2=A0 =C2=A0 =C2=A0 "from": "script/*" >> > =C2=A0 }, >> > =C2=A0 { >> > =C2=A0 =C2=A0 =C2=A0 "to": "style/*", >> > =C2=A0 =C2=A0 =C2=A0 "from": "style/*" >> > =C2=A0 }, >> > =C2=A0 { >> > =C2=A0 =C2=A0 =C2=A0 "to": "vendor/*", >> > =C2=A0 =C2=A0 =C2=A0 "from": "vendor/*" >> > =C2=A0 }, >> > =C2=A0 { >> > =C2=A0 =C2=A0"to": "../../*", >> > =C2=A0 =C2=A0"from": ":db/*" >> > =C2=A0 } >> > ] >> > >> > The last problem I have left is that although everything works (I have >> > indeed done some modifications to the templates, pathing function, etc= .. >> > nothing relevant to this current issue IMHO). >> > * >> > Except* one thing doesn't work as expected ... that is posting comment= s. >> I >> > have kinda narrowed it down that when the browser sends a new blog pos= t >> it >> > does PUT to address: '"/sofa/_design/sofa/_rewrite/sofa/spet-nov-post"= ' >> > (spet-nov-post is a _id - according to jquery.couch.js) >> > >> > While comment gets POST -ed to following URL: >> > '"/sofa/_design/sofa/_rewrite/sofa/"' >> > >> > what happens in the rewriter is following: >> > >> > 'PUT' /sofa/_design/sofa/_rewrite/sofa/spet-nov-post {1,1} -> 'PUT' >> > /sofa/spet-nov-post?db=3Dsofa {1,1} >> > 'POST' /sofa/_design/sofa/_rewrite/sofa/ {1,1} =C2=A0-> 'POST' >> > /sofa/_design/..?db=3Dsofa {1,1} >> > >> > I blame the following rewrite rule: >> > =C2=A0 { >> > =C2=A0 =C2=A0"to": "../../*", >> > =C2=A0 =C2=A0"from": ":db/*" >> > =C2=A0 } >> > >> > So using 2 rewrites rules work right ? (That what I suggested). For content-type This is something expected i think. Will re-read this separate issue later. Headers are not rewritten anyway. - beno=C3=AEt