[Mongrel] Long URLs - New to Mongrel

Bob Hutchison hutch at recursive.ca
Wed Mar 7 10:48:46 EST 2007


On 7-Mar-07, at 8:02 AM, Joe Lester wrote:

> My rails web app (rails 1.2.1) uploads an image from a Java applet by
> encoding it into the URL. This works fine when I'm using Webrick. I'm
> trying out Mongrel today, and I'm getting an error in Safari that
> says “lost network connection” (NSURLErrorDomain:-1005). I get
> something similar in Firefox. Is there a way to make Mongrel accept a
> really long URL like this?

Most servers will put a hard limit on the number of characters in a  
URL that they will accept. This is to avoid a kind of denial of  
service attack (imagine someone asking for a 10MB url repeatedly and  

Something else to think about is that GET is not supposed to be  
changing the state of the resource on the server. If you are trying  
to upload a file to the server using a GET you're breaking that rule.  
If you put that URL into a webpage, some browsers will 'optimise'  
your experience by pre-fetching. Imagine a webapp that had a delete  
record action implemented as a simple href on a page and a pre-fetch  
occurred... (and of course this has happened many many times).

The solution to both problems is to use POST. BTW, Rails link_to and  
url helpers support an option (:post => true) that will make this  
quite easy to accomplish. You can also have a confirm dialog with  
a :confirm => "Are you sure?" kind of thing.


> Thanks. Joe.
> I'm encoding the 512 x 512 jpeg image as Base64. The long URL is
> something like...
> http://localhost/account/upload?image=%2F9j%2F4AAQSkZJRgABAQAAAQABAAD%
> AQ
> AQ
> fA
> kM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1d 
> nd
> 4eXqDhIWGh4iJipKTlJWW......... [much more]
> When the URL is long, the action is not called in rails. But, if I
> remove the image from the URL, then the action is called.
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users

Bob Hutchison                  -- blogs at <http://www.recursive.ca/ 
Recursive Design Inc.          -- <http://www.recursive.ca/>
Raconteur                      -- <http://www.raconteur.info/>
xampl for Ruby                 -- <http://rubyforge.org/projects/xampl/>

More information about the Mongrel-users mailing list