Created
June 19, 2012 07:19
-
-
Save mkristian/2952760 to your computer and use it in GitHub Desktop.
jruby-rack-1.1.x can not handle PUT request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use jruby | |
$ ruby -v | |
jruby 1.6.4 (ruby-1.8.7-p330) (2011-08-23 17ea768) (JamVM 1.6.0_24) [linux-amd64-java] | |
$ gem install jetty-run | |
$ gem install rails | |
$ rails new dummy | |
$ cd dummy | |
$ rails g scaffold account name:string | |
$ rake db:mgrate | |
$ jetty-run | |
// other terminal for version 1.1.5 and 1.1.6 - other versions below | |
$ curl -X PUT -d "something=blabla&somethingelse=blaha" http://localhost:8080/accounts -i | |
HTTP/1.1 405 HTTP method PUT is not supported by this URL | |
Content-Length: 0 | |
Server: Jetty(7.6.4.v20120524) | |
// add Mavenfile (see below) and restart jetty - this mean jruby-rack 1.0.10 (or you can change to version 1.1.1 as well or version 1.1.4 also works) | |
$ curl -X PUT -d "something=blabla&somethingelse=blaha" http://localhost:8080/accounts/1 -i | |
HTTP/1.1 404 Not Found | |
Content-Type: text/html;charset=UTF-8 | |
Content-Length: 15392 | |
X-Request-Id: cd74288ca99d4c6ecc0fa6b511858450 | |
X-Runtime: 0.489000 | |
Server: Jetty(7.6.4.v20120524) | |
// with jruby-rack-1.1.2 (just change the version in Mavenfile) | |
$ curl -X PUT -d "something=blabla&somethingelse=blaha" http://localhost:8080/accounts/1 -i | |
HTTP/1.1 200 OK | |
Content-Type: text/html;charset=UTF-8 | |
Content-Length: 15388 | |
X-Request-Id: 95be9099686de5ef25445157e6b20001 | |
X-Runtime: 0.159000 | |
Server: Jetty(7.6.4.v20120524) | |
curl: (18) transfer closed with 15388 bytes remaining to read | |
// with jruby-rack-1.1.3 (just change the version in Mavenfile) | |
// BUT t reaches RAILS with expected | |
// ActiveRecord::RecordNotFound (Couldn't find Account with id=1): | |
$ curl -X PUT -d "something=blabla&somethingelse=blaha" http://localhost:8080/accounts/1 -i | |
HTTP/1.1 200 OK | |
Content-Type: text/html;charset=UTF-8 | |
Content-Length: 15388 | |
X-Request-Id: 95be9099686de5ef25445157e6b20001 | |
X-Runtime: 0.159000 | |
Server: Jetty(7.6.4.v20120524) | |
curl: (18) transfer closed with 15388 bytes remaining to read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jar 'org.jruby.rack:jruby-rack', '1.0.10' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE web-app PUBLIC | |
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | |
"http://java.sun.com/dtd/web-app_2_3.dtd"> | |
<web-app> | |
<welcome-file-list> | |
<welcome-file>/Rsl2/Rsl2.html</welcome-file> | |
</welcome-file-list> | |
<context-param> | |
<param-name>jruby.max.runtimes</param-name> | |
<param-value>1</param-value> | |
</context-param> | |
<context-param> | |
<param-name>jruby.min.runtimes</param-name> | |
<param-value>1</param-value> | |
</context-param> | |
<context-param> | |
<param-name>rails.root</param-name> | |
<param-value>.</param-value> | |
</context-param> | |
<context-param> | |
<param-name>gem.path</param-name> | |
<param-value>./target/rubygems</param-value> | |
</context-param> | |
<context-param> | |
<param-name>rails.env</param-name> | |
<param-value>development</param-value> | |
</context-param> | |
<context-param> | |
<param-name>jruby.rack.logging</param-name> | |
<param-value>stdout</param-value> | |
</context-param> | |
<context-param> | |
<param-name>jruby.rack.layout_class</param-name> | |
<param-value>JRuby::Rack::RailsFilesystemLayout</param-value> | |
</context-param> | |
<filter> | |
<filter-name>RackFilter</filter-name> | |
<filter-class>org.jruby.rack.RackFilter</filter-class> | |
</filter> | |
<filter-mapping> | |
<filter-name>RackFilter</filter-name> | |
<url-pattern>/*</url-pattern> | |
</filter-mapping> | |
<listener> | |
<listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class> | |
</listener> | |
</web-app> |
that works :) thanx.
a simple PUT/DELETE request that does not work out of the box - is a bug for me.
according to the docu the filter has advantages when serving static content.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try the following if you need to use the filter (otherwise you might go with the
RackServlet
instead) :