incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Lutterkort <lut...@redhat.com>
Subject Re: [PATCH] Add the driver to URLs returned.
Date Mon, 06 Jun 2011 09:49:57 GMT
On Fri, 2011-06-03 at 09:37 -0400, Chris Lalancette wrote:
> This patch fixes the problem by substituting in the REQUEST_URI
> (which contains the driver, if any) in the url_for method.  This
> seems to make things work for me.

I am having trouble with this: when I request
http://localhost:3001/api;driver=ec2?format=xml the server tries to load
the driver 'ec2?format=xml' which of course crashes and burns. I also
see env["HTTP_X_DELTACLOUD_DRIVER"]=ec2?format=xml hinting that the
matrix param processing code is where this issue originates

> Signed-off-by: Chris Lalancette <clalance@redhat.com>
> ---
>  server/lib/sinatra/url_for.rb |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/server/lib/sinatra/url_for.rb b/server/lib/sinatra/url_for.rb
> index 60da0ef..990c49c 100644
> --- a/server/lib/sinatra/url_for.rb
> +++ b/server/lib/sinatra/url_for.rb
> @@ -63,8 +63,14 @@ module Sinatra
>        # Don't add the base fragment if url_for gets called more than once
>        # per url or the url_fragment passed in is an absolute url
>        if url_escape.match(/^#{base}/) or url_escape.match(/^http/)
> +        # here, we assume that if any driver additions are needed, they have
> +        # been done prior to entering this method.  Hence we just return the
> +        # URL as-is
>          url_escape
>        else
> +        # one last thing we need to do here is to make sure we properly add
> +        # the driver type to the URL (if necessary)
> +        url_escape.sub!(/^\/api/, request.env['REQUEST_URI'])

You need to erase the query params from the REQUEST_URI, i.e.
request.env['REQUEST_URI'].sub(/\?.*$/, "")

David



Mime
View raw message