HTTP PUT method not enabled when running embedded jetty server
I use warbler gem to warble my Rails 4 application and add the executable feature so my war file can be run standalone. But when the embedded jetty server runs, all PUT methods send to it return something like this:
400 (HTTP method PUT is not supported by this URL)
I read from the web somewhere said jetty server by default disable HTTP PUT requests. How can I re-enable it ?
The web server support a custom config file now. You should be able to use this to enable it: https://github.com/jruby/warbler/blob/master/lib/warbler/web_server.rb#L125
Thanks for the reply. Can I kindly ask what is the config options to enable PUT request in jetty embedded server ?
I don't know. You'll have to look at the Jetty docs or ask on the mailing list
@simonykq Out of curiousity, what did you end up doing here?
Considering that Rails uses PUT/PATCH/DELETE requests out of box and the default embedded web server for Warbler is now Jetty, I can see quite a few people running into this same issue. Should the default configuration now enable PUT/PATCH/DELETE requests? Or maybe a Wiki page go up to show users how to do so?
Personally, I've spent a good chunk of my day scouring the web for resources. But as a Ruby-ist, the Java docs aren't very helpful nor do I have any experience with XML configuration of embedded Jetty to know where/what to do. The simplest option for me is to go back to embedded Winstone which doesn't seem to care what HTTP verb is passed in.
If I'm pointed in the right direction, I would gladly contribute this back to the project as I do feel bad making recommendations without any contribution. However I simply don't know where to begin in this case.
Thanks and sorry for the novel!
@tazsingh its actually not in the docs and even the mailing list is vague about it - so Java/XML are not to blame. thus to find out if jetty handles these VERBs (recall someone has been using those) someone has to spend a good chunk of his day on this :)
the problem surprises me since I am using jetty (including embedded jetty) with even PATCH verb without any extra config for jetty. jruby-rack does it all. just added a simple app which I used for integration tests here and there:
https://github.com/torquebox/jruby9-maven-plugins/tree/master/jruby9-extensions/src/it/jrubyWarExampleRubyDSL
with maven-3.3.x or ruby-maven gems (with rmvn) you can build the a warfile with embedded jetty.
so I would say we should look into warbler how it sets up embedded jetty. might find some time for it.
On Tue, Dec 8, 2015 at 6:09 AM, Karol Bucek [email protected] wrote:
@tazsingh https://github.com/tazsingh its actually not in the docs and even the mailing list is vague about it - so Java/XML are not to blame. thus to find out if jetty handles these VERBs (recall someone has been using those) someone has to spend a good chunk of his day on this :)
— Reply to this email directly or view it on GitHub https://github.com/jruby/warbler/issues/321#issuecomment-162767111.
Thanks @kares and @mkristian for the quick replies! Reporting back on my progress from yesterday:
Turns out that Jetty/Warbler does handle PUT/PATCH/DELETE requests without issue and with default configuration!
My particular issue was upstream and it looks like Nginx isn't accepting my PUT/PATCH/DELETE requests. I was thrown off by issues like this and other issues in Jetty leading me to believe that Jetty/Warbler was my issue at first. However after further digging, it turned out to be upstream Nginx.
Hopefully future people heading down this path see our comments and help them along their way. Integration tests would be wonderful as well @mkristian just to make sure the embedded server accepts all request types.
For people who may stumble on this via google search or something: we had this issue in one of our products and found that it was caused by the fact that nginx used HTTP 1.0 to talk to Jetty and something didn't quite work in that mode. Adding the following to our nginx config to force it to use HTTP 1.1 helped us resolve the issue:
proxy_http_version 1.1;
proxy_set_header Connection "";
FWIW, the same service worked perfectly behind haproxy without any hacks.