Skip to content

Commit 9227d75

Browse files
mkristiankares
authored andcommitted
allow PATCH verb to be processed by the ruby application
Sponsored by: Lookout, Inc. Conflicts: src/main/java/org/jruby/rack/UnmappedRackFilter.java src/spec/ruby/rack/filter_spec.rb
1 parent e2e7e43 commit 9227d75

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/main/java/org/jruby/rack/UnmappedRackFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public class UnmappedRackFilter extends AbstractFilter {
4848
private Collection<Integer> responseNotHandledStatuses =
4949
// 403 due containers not supporting PUT/DELETE correctly (Tomcat 6)
5050
// 405 returned by Jetty 7/8 on PUT/DELETE requests by default
51-
Collections.unmodifiableList( Arrays.asList(404, 403, 405) );
52-
51+
// 501 is returned for non standard http verbs like PATCH
52+
Collections.unmodifiableList( Arrays.asList(404, 403, 405, 501) );
5353
private RackContext context;
5454
private RackDispatcher dispatcher;
5555

src/spec/ruby/rack/filter_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ def stub_request(path_info)
8585
dispatcher.should_receive(:process).ordered
8686
filter.doFilter(@request, @response, chain)
8787
end
88+
89+
it "dispatches to the rack dispatcher if the chain resulted in a 501" do
90+
# non standard verbs like PATCH produce HTTP 501
91+
# see also http://httpstatus.es/501 and http://tools.ietf.org/html/rfc5789
92+
chain.should_receive(:doFilter).ordered.and_return do |_, resp|
93+
resp.sendError(501)
94+
end
95+
@response.should_receive(:reset)
96+
dispatcher.should_receive(:process)
97+
filter.doFilter(@request, @response, chain)
98+
end
8899

89100
it "dispatches to the rack dispatcher out of configured non handled statuses" do
90101
filter = Class.new(org.jruby.rack.RackFilter) do

0 commit comments

Comments
 (0)