File: bad.rb

package info (click to toggle)
ruby-excon 0.112.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,232 kB
  • sloc: ruby: 7,855; makefile: 5
file content (25 lines) | stat: -rwxr-xr-x 515 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env ruby

require "eventmachine"

module BadServer
  def receive_data(data)
    case data
    when %r{^GET /echo\s}
      send_data "HTTP/1.1 200 OK\r\n"
      send_data "\r\n"
      send_data data
      close_connection(true)
    when %r{^GET /eof/no_content_length_and_no_chunking\s}
      send_data "HTTP/1.1 200 OK\r\n"
      send_data "\r\n"
      send_data "hello"
      close_connection(true)
    end
  end
end

EM.run do
  EM.start_server("127.0.0.1", 9292, BadServer)
  $stderr.puts "ready"
end