Skip to content

Instantly share code, notes, and snippets.

@igrigorik
Created February 23, 2012 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igrigorik/1890923 to your computer and use it in GitHub Desktop.
Save igrigorik/1890923 to your computer and use it in GitHub Desktop.
missing content-length
require 'em-http'
EM.run do
r = EM::HttpRequest.new('http://localhost:24842').get
r.stream { |data| p [:stream, data] }
r.callback { p [:ok, r.response]; EM.stop }
r.errback { p [:fail, r.response]; EM.stop }
end
require 'eventmachine'
module BadResponse
def receive_data(data)
send_data("HTTP/1.1 200 OK\n\nBody Text -- Hello!")
end
end
EM.run do
Signal.trap("INT") { EventMachine.stop }
Signal.trap("TERM") { EventMachine.stop }
EventMachine::start_server '127.0.0.1', 24842, BadResponse
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment