1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added graceful handling of PUT, DELETE, and OPTIONS requests for a complete coverage of REST functionality #1136 [joshknowles@gmail.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1208 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-04-18 14:15:26 +00:00
parent a37b8b33d4
commit e9681eb9c5
3 changed files with 7 additions and 11 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* Added graceful handling of PUT, DELETE, and OPTIONS requests for a complete coverage of REST functionality #1136 [joshknowles@gmail.com]
* Fixed that you can now pass an alternative :href option to link_to_function/remote in order to point to somewhere other than # if the javascript fails or is turned off. You can do the same with form_remote_tag by passing in :action. #1113 [Sam Stephenson]
* Added Request#xml_http_request? (and an alias xhr?) to that'll return true when the request came from one of the Javascript helper methods (Ajax). This can be used to give one behavior for modern browsers supporting Ajax, another to old browsers #1127 [Sam Stephenson]

View file

@ -28,13 +28,9 @@ class CGI #:nodoc:
def read_query_params
case env_table['REQUEST_METHOD']
when 'GET', 'HEAD'
if defined? MOD_RUBY
Apache::request.args || ''
else
env_table['QUERY_STRING'] || ''
end
when 'POST'
when 'GET', 'HEAD', 'DELETE', 'OPTIONS'
(defined?(MOD_RUBY) ? Apache::request.args : env_table['QUERY_STRING']) || ''
when 'POST', 'PUT'
stdinput.binmode if stdinput.respond_to?(:binmode)
content = stdinput.read(Integer(env_table['CONTENT_LENGTH'])) || ''
env_table['RAW_POST_DATA'] = content.split("&_").first.to_s.freeze # &_ is a fix for Safari Ajax postings that always append \000

View file

@ -28,7 +28,7 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
super
end
def do_GET(req, res)
def service(req, res)
begin
unless handle_file(req, res)
REQUEST_MUTEX.lock
@ -41,12 +41,10 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
end
end
alias :do_POST :do_GET
def handle_file(req, res)
begin
add_dot_html(req)
@file_handler.send(:do_GET, req, res)
@file_handler.send(:service, req, res)
remove_dot_html(req)
return true
rescue HTTPStatus::PartialContent, HTTPStatus::NotModified => err