On Jun 6, 2011, at 11:49 AM, David Lutterkort wrote: > 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
I made a new patch, fixing params handling in matrix params and improving URI generation in url_for. I also added some unit tests to be sure that it works as expected.
Patch attached. -- Michal > >> Signed-off-by: Chris Lalancette <[email protected]> >> --- >> 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 > > ------------------------------------------------------ Michal Fojtik, [email protected] Deltacloud API: http://deltacloud.org
