#2 ✓resolved
Bryan Helmkamp

File attachment support

Reported by Bryan Helmkamp | April 28th, 2008 @ 03:57 AM

Comments and changes to this ticket

  • Bryan Helmkamp

    Bryan Helmkamp April 28th, 2008 @ 05:52 AM

    • State changed from “new” to “resolved”

    Merged from Kyle Hargraves in ce4dc1cd478cfec3a7379eeef8c8d3cd70e6782f.

  • Bryan Helmkamp

    Bryan Helmkamp March 8th, 2009 @ 06:59 PM

    (from [4e07f5b654018965c83425cd1fec14cdb8a87220]) Fix following of absolute redirect URL in Sinatra

    What's going on when the app redirects to an absolute URL?

    • Sinatra relies on Rack::MockSession which sets SERVER_NAME to "example.org" [1] on request it makes. However, Webrat expects it to be "www.example.com"

    • In MyClassyApp, the redirect URL is made out of Rack::Request#url [2] which uses SERVER_NAME, which is set to "example.org" by Rack::MockSession. As a result, Webrat see it as an external redirect and don't follow it.

    NOTE:

    • SERVER_NAME is stricly equivalent to HTTP_HOST [3]
    • This could have been fixed in Webrat::Session too. I'am not sure that it won't affect other frameworks so I left it intact.

      def request_page(url, http_method, data) #:nodoc:

       h = headers
       h['HTTP_REFERER'] = @current_url if @current_url
      
      
    •  h['HTTP_HOST']    = 'www.example.com'
      
      

    [1] http://github.com/rack/rack/blob... [2] http://github.com/rack/rack/blob... [3] http://github.com/rack/rack/blob... http://github.com/brynary/webrat...

  • Bryan Helmkamp

    Bryan Helmkamp March 8th, 2009 @ 06:59 PM

    (from [4e07f5b654018965c83425cd1fec14cdb8a87220]) Fix following of absolute redirect URL in Sinatra

    What's going on when the app redirects to an absolute URL?

    • Sinatra relies on Rack::MockSession which sets SERVER_NAME to "example.org" [1] on request it makes. However, Webrat expects it to be "www.example.com"

    • In MyClassyApp, the redirect URL is made out of Rack::Request#url [2] which uses SERVER_NAME, which is set to "example.org" by Rack::MockSession. As a result, Webrat see it as an external redirect and don't follow it.

    NOTE:

    • SERVER_NAME is stricly equivalent to HTTP_HOST [3]
    • This could have been fixed in Webrat::Session too. I'am not sure that it won't affect other frameworks so I left it intact.

      def request_page(url, http_method, data) #:nodoc:

       h = headers
       h['HTTP_REFERER'] = @current_url if @current_url
      
      
    •  h['HTTP_HOST']    = 'www.example.com'
      
      

    [1] http://github.com/rack/rack/blob... [2] http://github.com/rack/rack/blob... [3] http://github.com/rack/rack/blob... http://github.com/brynary/webrat...

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Referenced by

Pages