OmniAuth Google OpenID WEBrick::HTTPStatus::RequestURITooLarge
Asked Answered
H

5

17

I am using OmniAuth to allow users to log in with their Google OpenID accounts. When I try to log in in development mode with WEBrick, I get a WEBrick::HTTPStatus::RequestURITooLarge error. When I deploy it to my rails host, it works fine. Is there a different web server I should use instead of WEBrick?

Hanoi answered 7/2, 2011 at 21:21 Comment(0)
P
17

Strange, I wonder what the URI length limit is for WEBrick. You could try thin http://code.macournoyer.com/thin/. I use this locally for development sometimes and it seems to work great.

Perryperryman answered 8/2, 2011 at 5:13 Comment(3)
I have to admit, the URL is quite long... It contains a lot in the query stringHanoi
I would file a bug with OmniAuth or see if they provide a solution that doesn't use a query string.Perryperryman
Definitely a webrick limitation.Coarsen
S
11

As mentioned in railscast 236 for OmniAuth, WEBrick has trouble with long urls given by OpenID. The solution given that worked for me was to add Mongrel to your gemfile.

gem 'mongrel', '1.2.0.pre2'

Schubert answered 9/2, 2011 at 4:36 Comment(0)
Q
7

Add a file called webrick.rb file to the config\initializers directory.

if defined?(WEBrick::HTTPRequest)
  WEBrick::HTTPRequest.const_set("MAX_URI_LENGTH", 10240)
end
Quixote answered 7/3, 2013 at 1:31 Comment(1)
This is the best solution for me because it actually works with webrick.Perianth
B
3

The url size limit changed from 1024 to 2083 in the latest ruby source already. I hope an updated ruby version with this fix included will be released soon :)

https://github.com/ruby/ruby/blob/trunk/lib/webrick/httprequest.rb#L291

Bromleigh answered 3/7, 2011 at 10:41 Comment(2)
Usually Webrick is used for debugging so a small monkey-patch will not harm you ;)Guillaume
Yeah, but it's ugly and there's really no need for such a low limit...good they already fixed it :)Bromleigh
O
0

I ran into this same issue with Caseproof's DataTables gem using Webbrick and a table that had a lot of columns (> 15). Switching to the thin server resolved my issue as well. DataTables is a javascript/jquery plugin for creating tables.

Orrin answered 25/8, 2011 at 1:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.