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? 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% 2F2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ EBAQEBAQEBAQEBAQEBAQH% 2F2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ EBAQEBAQEBAQEBAQEBAQH%2FwAARCAIAAgADASIAAhEBAxEB% 2F8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL% 2F8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fA kM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd 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.
Whoa... why don''t you include the image in a POST body? Technically there''s no URL limit, but sending images using URL params sounds like a candidate for one of the blogs that I read... On 3/7/07, Joe Lester <joe_lester at sweetwater.com> 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? > > 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% > 2F2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ > EBAQEBAQEBAQEBAQEBAQH% > 2F2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ > EBAQEBAQEBAQEBAQEBAQH%2FwAARCAIAAgADASIAAhEBAxEB% > 2F8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL% > 2F8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fA > kM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd > 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070307/4211982e/attachment.html
Is it just me or is that an insane amount of data to send via GET? Mongrel is pretty strict about how clients use HTTP, so check your mongrel logs. On 3/7/07, Joe Lester <joe_lester at sweetwater.com> 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? > > 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% > 2F2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ > EBAQEBAQEBAQEBAQEBAQH% > 2F2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ > EBAQEBAQEBAQEBAQEBAQH%2FwAARCAIAAgADASIAAhEBAxEB% > 2F8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL% > 2F8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fA > kM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd > 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070307/f5447d44/attachment.html
The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15). My bad...still...that''s a lot of data. On 3/7/07, Patrick Berry <pberry at gmail.com> wrote:> > Is it just me or is that an insane amount of data to send via GET? > Mongrel is pretty strict about how clients use HTTP, so check your mongrel > logs. > > On 3/7/07, Joe Lester <joe_lester at sweetwater.com> 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? > > > > 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%<http://localhost/account/upload?image=%2F9j%2F4AAQSkZJRgABAQAAAQABAAD%25> > > 2F2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ > > > > EBAQEBAQEBAQEBAQEBAQH% > > 2F2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ > > EBAQEBAQEBAQEBAQEBAQH%2FwAARCAIAAgADASIAAhEBAxEB% > > 2F8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL% > > 2F8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fA > > > > kM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd > > 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 > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070307/b7cd1bed/attachment-0001.html
Hello Joe, 2007/3/7, Joe Lester <joe_lester at sweetwater.com>:> 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?Yes, Mongrel will kill the request because it thinks you''re trying to attack it. Why can''t you POST the data instead ? This is what POST was intended to do. Bye ! -- Fran?ois Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/
Joe Lester wrote:> My rails web app (rails 1.2.1) uploads an image from a Java applet by > encoding it into the URL.Why not use the POST method to upload the image... it can handle a lot more data than GET. http://en.wikipedia.org/wiki/HTTP#Request_methods -Steven
You realize that some browsers will complain about this, right? Having very long URLs is generally a bad idea. see also: http://www.boutell.com/newfaq/misc/urllength.html - Rob On 3/7/07, Joe Lester <joe_lester at sweetwater.com> 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? > > 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% > 2F2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ > EBAQEBAQEBAQEBAQEBAQH% > 2F2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ > EBAQEBAQEBAQEBAQEBAQH%2FwAARCAIAAgADASIAAhEBAxEB% > 2F8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL% > 2F8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fA > kM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd > 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 >
FYI, from RFC 2616 section 3.2.1: (http://www.w3.org/Protocols/ rfc2616/rfc2616-sec3.html) The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15). Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths. On Mar 7, 2007, at 8:49 AM, Patrick Berry wrote:> Is it just me or is that an insane amount of data to send via GET? > Mongrel is pretty strict about how clients use HTTP, so check your > mongrel logs. > > On 3/7/07, Joe Lester <joe_lester at sweetwater.com> 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? > > 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% > 2F2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB > AQ > EBAQEBAQEBAQEBAQEBAQH% > 2F2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB > AQ > EBAQEBAQEBAQEBAQEBAQH%2FwAARCAIAAgADASIAAhEBAxEB% > 2F8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL% > 2F8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0 > 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 > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070307/49a37c85/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2421 bytes Desc: not available Url : http://rubyforge.org/pipermail/mongrel-users/attachments/20070307/49a37c85/attachment.bin
Switching to POST. Thanks. On Mar 7, 2007, at 10:01 AM, Patrick Berry wrote:> The HTTP protocol does not place any a priori limit on the length of > a URI. Servers MUST be able to handle the URI of any resource they > serve, and SHOULD be able to handle URIs of unbounded length if > they > > provide GET-based forms that could generate such URIs. A server > SHOULD return 414 (Request-URI Too Long) status if a URI is longer > than the server can handle (see section 10.4.15). > My bad...still...that''s a lot of data. > > On 3/7/07, Patrick Berry <pberry at gmail.com> wrote: > Is it just me or is that an insane amount of data to send via GET? > Mongrel is pretty strict about how clients use HTTP, so check your > mongrel logs. > > > On 3/7/07, Joe Lester <joe_lester at sweetwater.com> 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? > > 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% > 2F2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB > AQ > EBAQEBAQEBAQEBAQEBAQH% > 2F2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB > AQ > EBAQEBAQEBAQEBAQEBAQH%2FwAARCAIAAgADASIAAhEBAxEB% > 2F8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL% > 2F8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0 > fA > kM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1d > nd > 4eXqDhIWGh4iJipKTlJWW......... [much more]-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070307/8e5119de/attachment.html
Hi, 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 frequently). 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. Cheers, Bob> > 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% > 2F2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB > AQ > EBAQEBAQEBAQEBAQEBAQH% > 2F2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB > AQ > EBAQEBAQEBAQEBAQEBAQH%2FwAARCAIAAgADASIAAhEBAxEB% > 2F8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL% > 2F8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0 > 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/ hutch/> Recursive Design Inc. -- <http://www.recursive.ca/> Raconteur -- <http://www.raconteur.info/> xampl for Ruby -- <http://rubyforge.org/projects/xampl/>
On Wed, 7 Mar 2007 08:02:23 -0500 Joe Lester <joe_lester at sweetwater.com> 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? > > Thanks. Joe.Joe, Mongrel enforces limits on the data it accepts in order to prevent various attacks. As many other folks mentioned you should probably be encoding that in a POST rather than GET request. Just for your reference, here''s the limits that you''ll hit: FIELD_NAME = 256 FIELD_VALUE = 80 * 1024 REQUEST_URI = 1024 * 12 REQUEST_PATH = 1024 QUERY_STRING = 1024 * 10 HEADER = 1024 * (80 + 32) FIELD_VALUE and HEADER limits are mostly to allow for the insane size of Cookies. You''re probably hitting the QUERY_STRING limit of 10k or the REQUEST_URI of 12k with your request. Have a good one. -- Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu http://www.zedshaw.com/ http://www.awprofessional.com/title/0321483502 -- The Mongrel Book http://mongrel.rubyforge.org/