couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From feiman <lfeiman...@gmail.com>
Subject Re: Strange issue with VHosts and rewrites...
Date Thu, 13 Jan 2011 02:25:01 GMT
unsubscribe

2011/1/11 Janez Štupar <janez.stupar@gmail.com>

> Here is the problem I'm currently dabbling around with Sofa (got it from
> 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  ->
> /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:
>
> [
>   {
>       "to": "_list/index/recent-posts",
>       "from": "blog/",
>       "query": {
>           "limit": 10,
>           "descending": true
>       }
>   },
>   {
>       "to": "_list/:listname/*",
>       "from": "list/:listname/*",
>       "query": {
>           "limit": 10,
>           "descending": true
>       }
>   },
>   {
>        "to" : "_show/:showname/*",
>        "from" : "show/:showname/*"
>   },
>   {
>         "to" : "_update/:updatename/*",
>         "from" : "update/:updatename/*"
>   },
>   {
>       "to": "_list/index/recent-posts",
>       "from": "",
>       "query": {
>           "limit": 10,
>           "descending": true
>       }
>   },
>   {
>       "to": "script/*",
>       "from": "script/*"
>   },
>   {
>       "to": "style/*",
>       "from": "style/*"
>   },
>   {
>       "to": "vendor/*",
>       "from": "vendor/*"
>   },
>   {
>    "to": "../../*",
>    "from": ":db/*"
>   }
> ]
>
> 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 comments. I
> have kinda narrowed it down that when the browser sends a new blog post 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=sofa {1,1}
> 'POST' /sofa/_design/sofa/_rewrite/sofa/ {1,1}  -> 'POST'
> /sofa/_design/..?db=sofa {1,1}
>
> I blame the following rewrite rule:
>   {
>    "to": "../../*",
>    "from": ":db/*"
>   }
>
> What is a mistery to me is why does the first request get rewritten
> correctly and the second not? AFAIK the second should come out as: 'POST'
> /sofa/?db=sofa {1,1}
>
> Below are the relevant logs -> The first is from new post creation (the PUT
> request), the other is from comment creation (the POST request).
>
> *First:
> *[Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.785.0>] Vhost Target:
> '"/sofa/_design/sofa/_rewrite/sofa/spet-nov-post"'
>
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.785.0>] 'PUT'
> /sofa/_design/sofa/_rewrite/sofa/spet-nov-post {1,1}
> Headers: [{'Accept',"application/json, text/javascript, */*"},
>          {'Accept-Charset',"UTF-8,*"},
>          {'Accept-Encoding',"gzip,deflate"},
>          {'Accept-Language',"en,sl;q=0.7,en-us;q=0.3"},
>          {'Connection',"keep-alive"},
>          {'Content-Length',"169"},
>          {'Content-Type',"application/json; charset=UTF-8"},
>
>
> {'Cookie',"AuthSession=Y291Y2hkYjo0RDI4Qzg3MTqTKp7crPdUFEbZrfJh-EiPaxh2tA"},
>          {'Host',"sofa.mycouch"},
>          {'Keep-Alive',"115"},
>          {'Referer',"http://sofa.mycouch/show/edit/"},
>          {'User-Agent',"Mozilla/5.0 (Windows; U; Windows NT 6.1; sl;
> rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729;
> .NET4.0C)"},
>          {"X-Requested-With","XMLHttpRequest"}]
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.785.0>] OAuth Params: []
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.785.0>] timeout 600
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.785.0>] Successful cookie auth
> as: "couchdb"
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.785.0>] rewrite to
> "/sofa/spet-nov-post?db=sofa"
>
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.785.0>] 'PUT'
> /sofa/spet-nov-post?db=sofa {1,1}
> Headers: [{'Accept',"application/json, text/javascript, */*"},
>          {'Accept-Charset',"UTF-8,*"},
>          {'Accept-Encoding',"gzip,deflate"},
>          {'Accept-Language',"en,sl;q=0.7,en-us;q=0.3"},
>          {'Connection',"keep-alive"},
>          {'Content-Length',"169"},
>          {'Content-Type',"application/json; charset=UTF-8"},
>
>
> {'Cookie',"AuthSession=Y291Y2hkYjo0RDI4Qzg3MTqTKp7crPdUFEbZrfJh-EiPaxh2tA"},
>          {'Host',"sofa.mycouch"},
>          {'Keep-Alive',"115"},
>          {'Referer',"http://sofa.mycouch/show/edit/"},
>          {'User-Agent',"Mozilla/5.0 (Windows; U; Windows NT 6.1; sl;
> rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729;
> .NET4.0C)"},
>          {"X-Requested-With","XMLHttpRequest"}]
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.785.0>] OAuth Params:
> [{"db","sofa"}]
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.785.0>] timeout 600
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.785.0>] Successful cookie auth
> as: "couchdb"
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.93.0>] DDocProc found for
> DDocKey: {<<"_design/sofa">>,
>                             <<"119-09fa3ceca488bfc1852ea48e3a0f0921">>}
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.630.0>] OS Process
> #Port<0.1421>
> Input  :: ["reset",{"reduce_limit":true}]
>
> [Sat, 08 Jan 2011 20:27:40 GMT] [debug] [<0.630.0>] OS Process
> #Port<0.1421>
> Output :: true
>
>
>
> *************************************************************************************
>
> *Second:*
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] Vhost Target:
> '"/sofa/_design/sofa/_rewrite/sofa/"'
>
>
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] 'POST'
> /sofa/_design/sofa/_rewrite/sofa/ {1,1}
> Headers: [{'Accept',"application/json, text/javascript, */*"},
>          {'Accept-Charset',"UTF-8,*"},
>          {'Accept-Encoding',"gzip,deflate"},
>          {'Accept-Language',"en,sl;q=0.7,en-us;q=0.3"},
>          {'Cache-Control',"no-cache"},
>          {'Connection',"keep-alive"},
>          {'Content-Length',"361"},
>          {'Content-Type',"application/json; charset=UTF-8"},
>
>
> {'Cookie',"AuthSession=Y291Y2hkYjo0RDI4QzhCQzqLGFFiyeUSKgz9OniE9_g41buHoQ"},
>          {'Host',"sofa.mycouch"},
>          {'Keep-Alive',"115"},
>          {'Pragma',"no-cache"},
>          {'Referer',"
> http://sofa.mycouch/list/post/post-page?startkey=%5B%22spet-nov-post%22%5D
> "},
>          {'User-Agent',"Mozilla/5.0 (Windows; U; Windows NT 6.1; sl;
> rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729;
> .NET4.0C)"},
>          {"X-Requested-With","XMLHttpRequest"}]
>
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] OAuth Params: []
>
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] timeout 600
>
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] Successful cookie auth
> as: "couchdb"
>
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] rewrite to
> "/sofa/_design/..?db=sofa"
>
>
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] 'POST'
> /sofa/_design/..?db=sofa {1,1}
> Headers: [{'Accept',"application/json, text/javascript, */*"},
>          {'Accept-Charset',"UTF-8,*"},
>          {'Accept-Encoding',"gzip,deflate"},
>          {'Accept-Language',"en,sl;q=0.7,en-us;q=0.3"},
>          {'Cache-Control',"no-cache"},
>          {'Connection',"keep-alive"},
>          {'Content-Length',"361"},
>          {'Content-Type',"application/json; charset=UTF-8"},
>
>
> {'Cookie',"AuthSession=Y291Y2hkYjo0RDI4QzhCQzqLGFFiyeUSKgz9OniE9_g41buHoQ"},
>          {'Host',"sofa.mycouch"},
>          {'Keep-Alive',"115"},
>          {'Pragma',"no-cache"},
>          {'Referer',"
> http://sofa.mycouch/list/post/post-page?startkey=%5B%22spet-nov-post%22%5D
> "},
>          {'User-Agent',"Mozilla/5.0 (Windows; U; Windows NT 6.1; sl;
> rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729;
> .NET4.0C)"},
>          {"X-Requested-With","XMLHttpRequest"}]
>
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] OAuth Params:
> [{"db","sofa"}]
>
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] timeout 600
>
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] Successful cookie auth
> as: "couchdb"
>
> [Sat, 08 Jan 2011 20:27:56 GMT] [debug] [<0.785.0>] Minor error in HTTP
> request: {bad_ctype,
>                                 "Content-Type must be multipart/form-data"}
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message