Last active
August 25, 2017 10:06
-
-
Save suhanlee/668461044d2ade0ea87299cf5ee1769a to your computer and use it in GitHub Desktop.
simple-em-synchrony-http-example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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