You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Sam Bisbee (JIRA)" <ji...@apache.org> on 2011/01/03 00:47:45 UTC

[jira] Created: (COUCHDB-1005) Rewriting to a URL with 2 replacements fails

Rewriting to a URL with 2 replacements fails
--------------------------------------------

                 Key: COUCHDB-1005
                 URL: https://issues.apache.org/jira/browse/COUCHDB-1005
             Project: CouchDB
          Issue Type: Bug
    Affects Versions: 1.0.1
            Reporter: Sam Bisbee


When I pull two variables out of a URL and drop them into the target, the target URL breaks. However, it appears that the variables are being captured appropriately.

This couch was built from source on Ubuntu 10.04 and is running a default config.

Unexpected Results
----------------------------
Assuming that we're querying the _rewrite handler with /foo/bar

{ "from": "/:user/:plugin", "to": "../../:user-:plugin"} will result in /db/undefined?user=foo&plugin=bar

{ "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/undefined?user=foo&plugin=bar

{ "from": "/:user/:plugin", "to": "../../:user"} will CORRECTLY result in /db/foo?user=foo&plugin=bar

Expected Results
------------------------
{ "from": "/:user/:plugin", "to": "../../:user-:plugin"} should result in /db/foo-bar?user=foo&plugin=bar

{ "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/foo bar?user=foo&plugin=bar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-1005) Rewriting to a URL with 2 replacements fails

Posted by "Benoit Chesneau (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976587#action_12976587 ] 

Benoit Chesneau commented on COUCHDB-1005:
------------------------------------------

The internal url use query parameter to skip a step to remove them rom parameters it doesn't hurt.

About the possibility to use ":var1:var2" it was discussed already on irc and on the ml. It would imply to use another kind of rewriting based on regexp or such. There is a consensus around on not using regexp in the rewriter.

What is the real usage of this rewriting ? Why not calling directly the docid ? ie:

from : "/:id",

where id = user%2Fplugin ?



> Rewriting to a URL with 2 replacements fails
> --------------------------------------------
>
>                 Key: COUCHDB-1005
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1005
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Sam Bisbee
>
> When I pull two variables out of a URL and drop them into the target, the target URL breaks. However, it appears that the variables are being captured appropriately.
> This couch was built from source on Ubuntu 10.04 and is running a default config.
> Unexpected Results
> ----------------------------
> Assuming that we're querying the _rewrite handler with /foo/bar
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user"} will CORRECTLY result in /db/foo?user=foo&plugin=bar
> Expected Results
> ------------------------
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} should result in /db/foo-bar?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/foo bar?user=foo&plugin=bar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (COUCHDB-1005) Rewriting to a URL with 2 replacements fails

Posted by "Sam Bisbee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1005?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sam Bisbee reopened COUCHDB-1005:
---------------------------------


Why wouldn't we want to allow this? It easily allows joining to create db names, doc ids, file attachment names, etc. This is a very direct use case for the rewriting functionality.

Ex., I'm storing items with doc ids that join :user and :plugin.

> Rewriting to a URL with 2 replacements fails
> --------------------------------------------
>
>                 Key: COUCHDB-1005
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1005
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Sam Bisbee
>
> When I pull two variables out of a URL and drop them into the target, the target URL breaks. However, it appears that the variables are being captured appropriately.
> This couch was built from source on Ubuntu 10.04 and is running a default config.
> Unexpected Results
> ----------------------------
> Assuming that we're querying the _rewrite handler with /foo/bar
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user"} will CORRECTLY result in /db/foo?user=foo&plugin=bar
> Expected Results
> ------------------------
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} should result in /db/foo-bar?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/foo bar?user=foo&plugin=bar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-1005) Rewriting to a URL with 2 replacements fails

Posted by "Volker Mische (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976703#action_12976703 ] 

Volker Mische commented on COUCHDB-1005:
----------------------------------------

I've hacked the rewriter to allow replacements of substrings (COUCHDB-1006). Would that solve your problem?


> Rewriting to a URL with 2 replacements fails
> --------------------------------------------
>
>                 Key: COUCHDB-1005
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1005
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Sam Bisbee
>
> When I pull two variables out of a URL and drop them into the target, the target URL breaks. However, it appears that the variables are being captured appropriately.
> This couch was built from source on Ubuntu 10.04 and is running a default config.
> Unexpected Results
> ----------------------------
> Assuming that we're querying the _rewrite handler with /foo/bar
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user"} will CORRECTLY result in /db/foo?user=foo&plugin=bar
> Expected Results
> ------------------------
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} should result in /db/foo-bar?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/foo bar?user=foo&plugin=bar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (COUCHDB-1005) Rewriting to a URL with 2 replacements fails

Posted by "Benoit Chesneau (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COUCHDB-1005?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benoit Chesneau resolved COUCHDB-1005.
--------------------------------------

    Resolution: Won't Fix

This is expected. Rewritingis based on path (ie each variable between slashes).

> Rewriting to a URL with 2 replacements fails
> --------------------------------------------
>
>                 Key: COUCHDB-1005
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1005
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Sam Bisbee
>
> When I pull two variables out of a URL and drop them into the target, the target URL breaks. However, it appears that the variables are being captured appropriately.
> This couch was built from source on Ubuntu 10.04 and is running a default config.
> Unexpected Results
> ----------------------------
> Assuming that we're querying the _rewrite handler with /foo/bar
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user"} will CORRECTLY result in /db/foo?user=foo&plugin=bar
> Expected Results
> ------------------------
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} should result in /db/foo-bar?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/foo bar?user=foo&plugin=bar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-1005) Rewriting to a URL with 2 replacements fails

Posted by "Sam Bisbee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976586#action_12976586 ] 

Sam Bisbee commented on COUCHDB-1005:
-------------------------------------

Also, embedding a slash like "to": "../../:user%2f:plugin/" causes the undefined error as well, so I can't have doc ids that concat strings with slashes either.

> Rewriting to a URL with 2 replacements fails
> --------------------------------------------
>
>                 Key: COUCHDB-1005
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1005
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Sam Bisbee
>
> When I pull two variables out of a URL and drop them into the target, the target URL breaks. However, it appears that the variables are being captured appropriately.
> This couch was built from source on Ubuntu 10.04 and is running a default config.
> Unexpected Results
> ----------------------------
> Assuming that we're querying the _rewrite handler with /foo/bar
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user"} will CORRECTLY result in /db/foo?user=foo&plugin=bar
> Expected Results
> ------------------------
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} should result in /db/foo-bar?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/foo bar?user=foo&plugin=bar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-1005) Rewriting to a URL with 2 replacements fails

Posted by "Benoit Chesneau (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976588#action_12976588 ] 

Benoit Chesneau commented on COUCHDB-1005:
------------------------------------------

can you post full log and example of urls ? I will check later in the coming day.

> Rewriting to a URL with 2 replacements fails
> --------------------------------------------
>
>                 Key: COUCHDB-1005
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1005
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Sam Bisbee
>
> When I pull two variables out of a URL and drop them into the target, the target URL breaks. However, it appears that the variables are being captured appropriately.
> This couch was built from source on Ubuntu 10.04 and is running a default config.
> Unexpected Results
> ----------------------------
> Assuming that we're querying the _rewrite handler with /foo/bar
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user"} will CORRECTLY result in /db/foo?user=foo&plugin=bar
> Expected Results
> ------------------------
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} should result in /db/foo-bar?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/foo bar?user=foo&plugin=bar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-1005) Rewriting to a URL with 2 replacements fails

Posted by "Sam Bisbee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976590#action_12976590 ] 

Sam Bisbee commented on COUCHDB-1005:
-------------------------------------

I have a virtual host that masks the database name and sends all requests to the rewriter (host:5984 -> /plugins/_design/app/_rewrite). I'm using rewrite because the files I'm storing data on, and the files themselves, are being served in a non-REST conforming scheme. I have to do some string manipulation to bridge that gap, and don't see a reason to bolt on an additional app layer or putting app logic into my httpd/proxy. Especially when this seems to be a clear cut use case of the rewrite system.

Thanks for taking a look at this!

----

"rewrites": [
       {
           "from": "/:user/:plugin",
           "to": "../../:user%2f:plugin/"
       }
   ]

then I request /cowboy/bbq

'GET' /plugins/undefined?user=cowboy&plugin=bbq 404

----

"rewrites": [
       {
           "from": "/:user/:plugin",
           "to": "../../:user/:plugin/"
       }
   ]

then I request /cowboy/bbq

'GET' /plugins/cowboy/bbq?user=cowboy&plugin=bbq 404

(The embedded slash is needed, but as seen in the previous example, embedded slashes the same "that's not a slash" issue.)

----

"rewrites": [
       {
           "from": "/:user/:plugin",
           "to": "../../:user-:plugin/"
       }
   ]

then I request /cowboy/bbq

'GET' /plugins/undefined?user=cowboy&plugin=bbq 404

> Rewriting to a URL with 2 replacements fails
> --------------------------------------------
>
>                 Key: COUCHDB-1005
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1005
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Sam Bisbee
>
> When I pull two variables out of a URL and drop them into the target, the target URL breaks. However, it appears that the variables are being captured appropriately.
> This couch was built from source on Ubuntu 10.04 and is running a default config.
> Unexpected Results
> ----------------------------
> Assuming that we're querying the _rewrite handler with /foo/bar
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user"} will CORRECTLY result in /db/foo?user=foo&plugin=bar
> Expected Results
> ------------------------
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} should result in /db/foo-bar?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/foo bar?user=foo&plugin=bar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-1005) Rewriting to a URL with 2 replacements fails

Posted by "Benoit Chesneau (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976710#action_12976710 ] 

Benoit Chesneau commented on COUCHDB-1005:
------------------------------------------

This feature worth a discussion on the mailing-list.. There have been long discussion about the rewriting feature. First intention of _rewriter was to offer a simple way to dispatch urls to a resource (_show, _update, _list, _view, doc, attachment) based on path terms (string, ':var", "*"). Path specifications are obtained by breaking url into tokens via the "/" separator, Then we match them against path terms. That's how we find urls. There is also the possibility to use query arguments as a path term. 

The rewriter like this is the easier implementation we found, and as is the only that obtained a consensus between devs.

Now I understand people want to do more mostly because of CouchApp concept and the need to reduce the stack between couchdb and the web (removing a proxy, app middleware, ...) . But before adding more features to couch_httpd_rewriter I would like to take some time to define final intention of this rewriter. I always considered the rewriter as a temporary hack before we go for a full app engine inside couch (and that without having to proxy it to a server). Maybe it's time to think about it more. I have a working implementation I will opensource this week when I'm back. 

But I guess it will take some time before any app-engine implementation come into trunk and goals of this one should be discussed. Waiting that does it worth to work on an improved but more complex rewriter ? I like the replace concept, since it doesn't break current implementation, didn't see the code yet, but could be a way to support an improved rewriter without adding more complexity I guess.

> Rewriting to a URL with 2 replacements fails
> --------------------------------------------
>
>                 Key: COUCHDB-1005
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1005
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Sam Bisbee
>
> When I pull two variables out of a URL and drop them into the target, the target URL breaks. However, it appears that the variables are being captured appropriately.
> This couch was built from source on Ubuntu 10.04 and is running a default config.
> Unexpected Results
> ----------------------------
> Assuming that we're querying the _rewrite handler with /foo/bar
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user"} will CORRECTLY result in /db/foo?user=foo&plugin=bar
> Expected Results
> ------------------------
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} should result in /db/foo-bar?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/foo bar?user=foo&plugin=bar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COUCHDB-1005) Rewriting to a URL with 2 replacements fails

Posted by "Sam Bisbee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COUCHDB-1005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976932#action_12976932 ] 

Sam Bisbee commented on COUCHDB-1005:
-------------------------------------

While I'm all for a more feature rich rewrite/regex engine after benchmarking, I don't think it's needed to fulfill the needs of this ticket. The current implementation already allows for URLs to be built using multiple variables, as long as they are separated by a slash. All that needs to happen is to have that restriction lifted - allow >=0 characters as separators. Even allowing >=1 character would be a huge improvement, because it would allow document ids to be built, while we currently can only build URLs.

Of course, I don't know the internals well enough, but an educated guess/feeling says that this shouldn't be too tricky. Or am I missing a piece of complexity?

Cheers.

> Rewriting to a URL with 2 replacements fails
> --------------------------------------------
>
>                 Key: COUCHDB-1005
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1005
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Sam Bisbee
>
> When I pull two variables out of a URL and drop them into the target, the target URL breaks. However, it appears that the variables are being captured appropriately.
> This couch was built from source on Ubuntu 10.04 and is running a default config.
> Unexpected Results
> ----------------------------
> Assuming that we're querying the _rewrite handler with /foo/bar
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/undefined?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user"} will CORRECTLY result in /db/foo?user=foo&plugin=bar
> Expected Results
> ------------------------
> { "from": "/:user/:plugin", "to": "../../:user-:plugin"} should result in /db/foo-bar?user=foo&plugin=bar
> { "from": "/:user/:plugin", "to": "../../:user :plugin"} will result in /db/foo bar?user=foo&plugin=bar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.