Skip to content

Instantly share code, notes, and snippets.

@suhanlee
Last active August 25, 2017 10:06
Show Gist options
  • Save suhanlee/668461044d2ade0ea87299cf5ee1769a to your computer and use it in GitHub Desktop.
Save suhanlee/668461044d2ade0ea87299cf5ee1769a to your computer and use it in GitHub Desktop.
simple-em-synchrony-http-example
require 'pp'
require 'em-synchrony'
require 'em-synchrony/em-http'
require 'em-synchrony/fiber_iterator'
POST_URL = "http://localhost:4567/post_test"
GET_URL = "http://localhost:4567/get_test"
EM.synchrony do
1.times do |n|
post_http = EventMachine::HttpRequest.new(POST_URL).post :body => {'test' => '123'}
p post_http.response_header.status
p post_http.response
get_http = EventMachine::HttpRequest.new(GET_URL).get :query => {'test' => '123'}
p get_http.response_header.status
p get_http.response
end
EventMachine.stop
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment