~ubuntu-branches/ubuntu/utopic/ruby-excon/utopic

« back to all changes in this revision

Viewing changes to tests/servers/error.rb

  • Committer: Package Import Robot
  • Author(s): Laurent Bigonville
  • Date: 2013-07-06 23:48:43 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130706234843-vyj5m4o7q6hlhwo4
Tags: 0.25.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require "eventmachine"
 
4
 
 
5
module ErrorServer
 
6
  def receive_data(data)
 
7
    case data
 
8
    when %r{^GET /error/not_found\s}
 
9
      send_data "HTTP/1.1 404 Not Found\r\n"
 
10
      send_data "\r\n"
 
11
      send_data "server says not found"
 
12
      close_connection(true)
 
13
    end
 
14
  end
 
15
end
 
16
 
 
17
EM.run do
 
18
  EM.start_server("127.0.0.1", 9292, ErrorServer)
 
19
  $stderr.puts "ready"
 
20
end