spec/support/test_server.rb in patron-0.9.1 vs spec/support/test_server.rb in patron-0.10.0

- old
+ new

@@ -1,31 +1,9 @@ ## ------------------------------------------------------------------- ## ## Patron HTTP Client: HTTP test server for integration tests -## Copyright (c) 2008 The Hive http://www.thehive.com/ -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included in -## all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -## THE SOFTWARE. -## -## ------------------------------------------------------------------- - require 'yaml' require 'webrick' require 'webrick/https' require 'openssl' require 'zlib' @@ -100,10 +78,18 @@ def do_GET(req,res) sleep(1.1) end end +class SlowServlet < HTTPServlet::AbstractServlet + def do_GET(req,res) + sleep 3 + res.header['Content-Type'] = 'text/plain' + res.body = 'beep' + end +end + class RedirectServlet < HTTPServlet::AbstractServlet def do_GET(req,res) res['Location'] = "http://localhost:9001/test" res.status = 301 end @@ -201,9 +187,10 @@ @server.mount("/test", TestServlet) @server.mount("/testpost", TestPostBodyServlet) @server.mount("/testpatch", TestPatchBodyServlet) @server.mount("/timeout", TimeoutServlet) + @server.mount("/slow", SlowServlet) @server.mount("/redirect", RedirectServlet) @server.mount("/evil-redirect", EvilRedirectServlet) @server.mount("/picture", PictureServlet) @server.mount("/very-large", LargeServlet) @server.mount("/setcookie", SetCookieServlet)