eventmachine 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +9 -0
 - data/ext/ed.cpp +3 -2
 - data/ext/em.cpp +12 -6
 - data/ext/em.h +1 -1
 - data/ext/extconf.rb +1 -1
 - data/ext/rubymain.cpp +8 -1
 - data/lib/em/protocols/httpclient.rb +1 -0
 - data/lib/em/version.rb +1 -1
 - data/lib/jeventmachine.rb +2 -2
 - data/tests/test_basic.rb +1 -1
 - data/tests/test_connection_count.rb +31 -2
 - data/tests/test_file_watch.rb +19 -0
 - data/tests/test_httpclient.rb +33 -28
 - data/tests/test_httpclient2.rb +26 -26
 - data/tests/test_idle_connection.rb +24 -18
 - data/tests/test_ipv4.rb +70 -100
 - data/tests/test_ipv6.rb +0 -26
 - data/tests/test_iterator.rb +19 -16
 - data/tests/test_ltp.rb +28 -11
 - data/tests/test_pending_connect_timeout.rb +3 -3
 - data/tests/test_resolver.rb +4 -3
 - data/tests/test_sock_opt.rb +54 -0
 - data/tests/test_stomp.rb +11 -10
 - data/tests/test_unbind_reason.rb +14 -26
 - metadata +4 -6
 - data/tests/test_get_sock_opt.rb +0 -37
 - data/tests/test_set_sock_opt.rb +0 -39
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 36a220365872f603cdcf0fa1d9ff74cb262f0e01
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f2c20894debc62a45a5369426bc470415e2ee68d
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: cd3e24582a33fb6aae96d64b17c93140e9a9a20aad4b4f33f08f4c363ba20233e0e3188de70d1afe6f59d064dbc04721cc028cdfcc7ac37c1c516c4c1c7a972a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8a2bfebaa1e5c8867f31b8bfce064f18fff0e7d913f7d3ccd60f7b13e1cf2601d8ede8cf8fad0cafb1ddd35c8f3bbe7ba08c12a5b5ac178a68fc61d062c42523
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Changelog
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## 1.2.2 (January 23, 2016)
         
     | 
| 
      
 4 
     | 
    
         
            +
            * Java: Fix Fixnum deprecated warning in Ruby 2.4+ [#759]
         
     | 
| 
      
 5 
     | 
    
         
            +
            * Fix uncaught C++ exception in file watcher and raise InvalidSignature [#512, #757]
         
     | 
| 
      
 6 
     | 
    
         
            +
            * Fix connection count off-by-one for epoll and kqueue [#750]
         
     | 
| 
      
 7 
     | 
    
         
            +
            * Fix uninitialized variable warning in EM::P::HttpClient [#749]
         
     | 
| 
      
 8 
     | 
    
         
            +
            * Fix missing initial value for EventableDescriptor NextHeartbeat [#748]
         
     | 
| 
      
 9 
     | 
    
         
            +
            * Fix hostname resolution on Solaris, Ilumos, SmartOS, et al [#745, #746]
         
     | 
| 
      
 10 
     | 
    
         
            +
            * Improve reliability of tests, reduce public Internet accesses in tests [#656, #666, #749]
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       3 
12 
     | 
    
         
             
            ## 1.2.1 (November 15, 2016)
         
     | 
| 
       4 
13 
     | 
    
         
             
            * Throw strerror(errno) when getsockname or getpeername fail [#683]
         
     | 
| 
       5 
14 
     | 
    
         
             
            * Use a single concrete implementation of getpeername/getsockname, the rest pure virtuals [#683]
         
     | 
    
        data/ext/ed.cpp
    CHANGED
    
    | 
         @@ -84,6 +84,7 @@ EventableDescriptor::EventableDescriptor (SOCKET sd, EventMachine_t *em): 
     | 
|
| 
       84 
84 
     | 
    
         
             
            	MyEventMachine (em),
         
     | 
| 
       85 
85 
     | 
    
         
             
            	PendingConnectTimeout(20000000),
         
     | 
| 
       86 
86 
     | 
    
         
             
            	InactivityTimeout (0),
         
     | 
| 
      
 87 
     | 
    
         
            +
            	NextHeartbeat (0),
         
     | 
| 
       87 
88 
     | 
    
         
             
            	bPaused (false)
         
     | 
| 
       88 
89 
     | 
    
         
             
            {
         
     | 
| 
       89 
90 
     | 
    
         
             
            	/* There are three ways to close a socket, all of which should
         
     | 
| 
         @@ -112,12 +113,12 @@ EventableDescriptor::EventableDescriptor (SOCKET sd, EventMachine_t *em): 
     | 
|
| 
       112 
113 
     | 
    
         
             
            	if (MyEventMachine == NULL)
         
     | 
| 
       113 
114 
     | 
    
         
             
            		throw std::runtime_error ("bad em in eventable descriptor");
         
     | 
| 
       114 
115 
     | 
    
         
             
            	CreatedAt = MyEventMachine->GetCurrentLoopTime();
         
     | 
| 
      
 116 
     | 
    
         
            +
            	LastActivity = MyEventMachine->GetCurrentLoopTime();
         
     | 
| 
       115 
117 
     | 
    
         | 
| 
       116 
118 
     | 
    
         
             
            	#ifdef HAVE_EPOLL
         
     | 
| 
       117 
119 
     | 
    
         
             
            	EpollEvent.events = 0;
         
     | 
| 
       118 
120 
     | 
    
         
             
            	EpollEvent.data.ptr = this;
         
     | 
| 
       119 
121 
     | 
    
         
             
            	#endif
         
     | 
| 
       120 
     | 
    
         
            -
            	LastActivity = MyEventMachine->GetCurrentLoopTime();
         
     | 
| 
       121 
122 
     | 
    
         
             
            }
         
     | 
| 
       122 
123 
     | 
    
         | 
| 
       123 
124 
     | 
    
         | 
| 
         @@ -1944,7 +1945,7 @@ int DatagramDescriptor::SendOutboundDatagram (const char *data, unsigned long le 
     | 
|
| 
       1944 
1945 
     | 
    
         | 
| 
       1945 
1946 
     | 
    
         
             
            	struct sockaddr_in6 addr_here;
         
     | 
| 
       1946 
1947 
     | 
    
         
             
            	size_t addr_here_len = sizeof addr_here;
         
     | 
| 
       1947 
     | 
    
         
            -
            	if (0 != EventMachine_t::name2address (address, port, (struct sockaddr *)&addr_here, &addr_here_len))
         
     | 
| 
      
 1948 
     | 
    
         
            +
            	if (0 != EventMachine_t::name2address (address, port, SOCK_DGRAM, (struct sockaddr *)&addr_here, &addr_here_len))
         
     | 
| 
       1948 
1949 
     | 
    
         
             
            		return -1;
         
     | 
| 
       1949 
1950 
     | 
    
         | 
| 
       1950 
1951 
     | 
    
         
             
            	if (!data && (length > 0))
         
     | 
    
        data/ext/em.cpp
    CHANGED
    
    | 
         @@ -1194,7 +1194,7 @@ const uintptr_t EventMachine_t::ConnectToServer (const char *bind_addr, int bind 
     | 
|
| 
       1194 
1194 
     | 
    
         | 
| 
       1195 
1195 
     | 
    
         
             
            	struct sockaddr_storage bind_as;
         
     | 
| 
       1196 
1196 
     | 
    
         
             
            	size_t bind_as_len = sizeof bind_as;
         
     | 
| 
       1197 
     | 
    
         
            -
            	int gai = name2address (server, port, (struct sockaddr *)&bind_as, &bind_as_len);
         
     | 
| 
      
 1197 
     | 
    
         
            +
            	int gai = name2address (server, port, SOCK_STREAM, (struct sockaddr *)&bind_as, &bind_as_len);
         
     | 
| 
       1198 
1198 
     | 
    
         
             
            	if (gai != 0) {
         
     | 
| 
       1199 
1199 
     | 
    
         
             
            		char buf [200];
         
     | 
| 
       1200 
1200 
     | 
    
         
             
            		snprintf (buf, sizeof(buf)-1, "unable to resolve address: %s", gai_strerror(gai));
         
     | 
| 
         @@ -1223,7 +1223,7 @@ const uintptr_t EventMachine_t::ConnectToServer (const char *bind_addr, int bind 
     | 
|
| 
       1223 
1223 
     | 
    
         
             
            	if (bind_addr) {
         
     | 
| 
       1224 
1224 
     | 
    
         
             
            		struct sockaddr_storage bind_to;
         
     | 
| 
       1225 
1225 
     | 
    
         
             
            		size_t bind_to_len = sizeof bind_to;
         
     | 
| 
       1226 
     | 
    
         
            -
            		gai = name2address (bind_addr, bind_port, (struct sockaddr *)&bind_to, &bind_to_len);
         
     | 
| 
      
 1226 
     | 
    
         
            +
            		gai = name2address (bind_addr, bind_port, SOCK_STREAM, (struct sockaddr *)&bind_to, &bind_to_len);
         
     | 
| 
       1227 
1227 
     | 
    
         
             
            		if (gai != 0) {
         
     | 
| 
       1228 
1228 
     | 
    
         
             
            			close (sd);
         
     | 
| 
       1229 
1229 
     | 
    
         
             
            			char buf [200];
         
     | 
| 
         @@ -1543,7 +1543,7 @@ int EventMachine_t::DetachFD (EventableDescriptor *ed) 
     | 
|
| 
       1543 
1543 
     | 
    
         
             
            name2address
         
     | 
| 
       1544 
1544 
     | 
    
         
             
            ************/
         
     | 
| 
       1545 
1545 
     | 
    
         | 
| 
       1546 
     | 
    
         
            -
            int EventMachine_t::name2address (const char *server, int port, struct sockaddr *addr, size_t *addr_len)
         
     | 
| 
      
 1546 
     | 
    
         
            +
            int EventMachine_t::name2address (const char *server, int port, int socktype, struct sockaddr *addr, size_t *addr_len)
         
     | 
| 
       1547 
1547 
     | 
    
         
             
            {
         
     | 
| 
       1548 
1548 
     | 
    
         
             
            	if (!server || !*server)
         
     | 
| 
       1549 
1549 
     | 
    
         
             
            		server = "0.0.0.0";
         
     | 
| 
         @@ -1551,6 +1551,7 @@ int EventMachine_t::name2address (const char *server, int port, struct sockaddr 
     | 
|
| 
       1551 
1551 
     | 
    
         
             
            	struct addrinfo *ai;
         
     | 
| 
       1552 
1552 
     | 
    
         
             
            	struct addrinfo hints;
         
     | 
| 
       1553 
1553 
     | 
    
         
             
            	memset (&hints, 0, sizeof(hints));
         
     | 
| 
      
 1554 
     | 
    
         
            +
            	hints.ai_socktype = socktype;
         
     | 
| 
       1554 
1555 
     | 
    
         
             
            	hints.ai_family = AF_UNSPEC;
         
     | 
| 
       1555 
1556 
     | 
    
         
             
            	hints.ai_flags = AI_NUMERICSERV | AI_ADDRCONFIG;
         
     | 
| 
       1556 
1557 
     | 
    
         | 
| 
         @@ -1584,7 +1585,7 @@ const uintptr_t EventMachine_t::CreateTcpServer (const char *server, int port) 
     | 
|
| 
       1584 
1585 
     | 
    
         | 
| 
       1585 
1586 
     | 
    
         
             
            	struct sockaddr_storage bind_here;
         
     | 
| 
       1586 
1587 
     | 
    
         
             
            	size_t bind_here_len = sizeof bind_here;
         
     | 
| 
       1587 
     | 
    
         
            -
            	if (0 != name2address (server, port, (struct sockaddr *)&bind_here, &bind_here_len))
         
     | 
| 
      
 1588 
     | 
    
         
            +
            	if (0 != name2address (server, port, SOCK_STREAM, (struct sockaddr *)&bind_here, &bind_here_len))
         
     | 
| 
       1588 
1589 
     | 
    
         
             
            		return 0;
         
     | 
| 
       1589 
1590 
     | 
    
         | 
| 
       1590 
1591 
     | 
    
         
             
            	SOCKET sd_accept = EmSocket (bind_here.ss_family, SOCK_STREAM, 0);
         
     | 
| 
         @@ -1639,7 +1640,7 @@ const uintptr_t EventMachine_t::OpenDatagramSocket (const char *address, int por 
     | 
|
| 
       1639 
1640 
     | 
    
         | 
| 
       1640 
1641 
     | 
    
         
             
            	struct sockaddr_storage bind_here;
         
     | 
| 
       1641 
1642 
     | 
    
         
             
            	size_t bind_here_len = sizeof bind_here;
         
     | 
| 
       1642 
     | 
    
         
            -
            	if (0 != name2address (address, port, (struct sockaddr *)&bind_here, &bind_here_len))
         
     | 
| 
      
 1643 
     | 
    
         
            +
            	if (0 != name2address (address, port, SOCK_DGRAM, (struct sockaddr *)&bind_here, &bind_here_len))
         
     | 
| 
       1643 
1644 
     | 
    
         
             
            		return 0;
         
     | 
| 
       1644 
1645 
     | 
    
         | 
| 
       1645 
1646 
     | 
    
         
             
            	// from here on, early returns must close the socket!
         
     | 
| 
         @@ -2087,7 +2088,12 @@ EventMachine_t::GetConnectionCount 
     | 
|
| 
       2087 
2088 
     | 
    
         | 
| 
       2088 
2089 
     | 
    
         
             
            int EventMachine_t::GetConnectionCount ()
         
     | 
| 
       2089 
2090 
     | 
    
         
             
            {
         
     | 
| 
       2090 
     | 
    
         
            -
            	 
     | 
| 
      
 2091 
     | 
    
         
            +
            	int i = 0;
         
     | 
| 
      
 2092 
     | 
    
         
            +
            	// Subtract one for epoll or kqueue because of the LoopbreakDescriptor
         
     | 
| 
      
 2093 
     | 
    
         
            +
            	if (Poller == Poller_Epoll || Poller == Poller_Kqueue)
         
     | 
| 
      
 2094 
     | 
    
         
            +
            		i = 1;
         
     | 
| 
      
 2095 
     | 
    
         
            +
             
     | 
| 
      
 2096 
     | 
    
         
            +
            	return Descriptors.size() + NewDescriptors.size() - i;
         
     | 
| 
       2091 
2097 
     | 
    
         
             
            }
         
     | 
| 
       2092 
2098 
     | 
    
         | 
| 
       2093 
2099 
     | 
    
         | 
    
        data/ext/em.h
    CHANGED
    
    | 
         @@ -201,7 +201,7 @@ class EventMachine_t 
     | 
|
| 
       201 
201 
     | 
    
         | 
| 
       202 
202 
     | 
    
         
             
            		Poller_t GetPoller() { return Poller; }
         
     | 
| 
       203 
203 
     | 
    
         | 
| 
       204 
     | 
    
         
            -
            		static int name2address (const char *server, int port, struct sockaddr *addr, size_t *addr_len);
         
     | 
| 
      
 204 
     | 
    
         
            +
            		static int name2address (const char *server, int port, int socktype, struct sockaddr *addr, size_t *addr_len);
         
     | 
| 
       205 
205 
     | 
    
         | 
| 
       206 
206 
     | 
    
         
             
            	private:
         
     | 
| 
       207 
207 
     | 
    
         
             
            		void _RunTimers();
         
     | 
    
        data/ext/extconf.rb
    CHANGED
    
    | 
         @@ -70,7 +70,7 @@ def pkg_config_wrapper(pretty_name, name) 
     | 
|
| 
       70 
70 
     | 
    
         
             
            end
         
     | 
| 
       71 
71 
     | 
    
         | 
| 
       72 
72 
     | 
    
         
             
            if ENV['CROSS_COMPILING']
         
     | 
| 
       73 
     | 
    
         
            -
              openssl_version = ENV.fetch("OPENSSL_VERSION", "1.0. 
     | 
| 
      
 73 
     | 
    
         
            +
              openssl_version = ENV.fetch("OPENSSL_VERSION", "1.0.2j")
         
     | 
| 
       74 
74 
     | 
    
         
             
              openssl_dir = File.expand_path("~/.rake-compiler/builds/openssl-#{openssl_version}/")
         
     | 
| 
       75 
75 
     | 
    
         
             
              if File.exist?(openssl_dir)
         
     | 
| 
       76 
76 
     | 
    
         
             
                FileUtils.mkdir_p Dir.pwd+"/openssl/"
         
     | 
    
        data/ext/rubymain.cpp
    CHANGED
    
    | 
         @@ -58,6 +58,7 @@ static VALUE EM_eConnectionError; 
     | 
|
| 
       58 
58 
     | 
    
         
             
            static VALUE EM_eUnknownTimerFired;
         
     | 
| 
       59 
59 
     | 
    
         
             
            static VALUE EM_eConnectionNotBound;
         
     | 
| 
       60 
60 
     | 
    
         
             
            static VALUE EM_eUnsupported;
         
     | 
| 
      
 61 
     | 
    
         
            +
            static VALUE EM_eInvalidSignature;
         
     | 
| 
       61 
62 
     | 
    
         | 
| 
       62 
63 
     | 
    
         
             
            static VALUE Intern_at_signature;
         
     | 
| 
       63 
64 
     | 
    
         
             
            static VALUE Intern_at_timers;
         
     | 
| 
         @@ -1036,7 +1037,12 @@ t_unwatch_filename 
     | 
|
| 
       1036 
1037 
     | 
    
         | 
| 
       1037 
1038 
     | 
    
         
             
            static VALUE t_unwatch_filename (VALUE self UNUSED, VALUE sig)
         
     | 
| 
       1038 
1039 
     | 
    
         
             
            {
         
     | 
| 
       1039 
     | 
    
         
            -
            	 
     | 
| 
      
 1040 
     | 
    
         
            +
            	try {
         
     | 
| 
      
 1041 
     | 
    
         
            +
            		evma_unwatch_filename(NUM2BSIG (sig));
         
     | 
| 
      
 1042 
     | 
    
         
            +
            	} catch (std::runtime_error e) {
         
     | 
| 
      
 1043 
     | 
    
         
            +
            		rb_raise (EM_eInvalidSignature, "%s", e.what());
         
     | 
| 
      
 1044 
     | 
    
         
            +
            	}
         
     | 
| 
      
 1045 
     | 
    
         
            +
            	
         
     | 
| 
       1040 
1046 
     | 
    
         
             
            	return Qnil;
         
     | 
| 
       1041 
1047 
     | 
    
         
             
            }
         
     | 
| 
       1042 
1048 
     | 
    
         | 
| 
         @@ -1389,6 +1395,7 @@ extern "C" void Init_rubyeventmachine() 
     | 
|
| 
       1389 
1395 
     | 
    
         
             
            	EM_eConnectionNotBound = rb_define_class_under (EmModule, "ConnectionNotBound", rb_eRuntimeError);
         
     | 
| 
       1390 
1396 
     | 
    
         
             
            	EM_eUnknownTimerFired = rb_define_class_under (EmModule, "UnknownTimerFired", rb_eRuntimeError);
         
     | 
| 
       1391 
1397 
     | 
    
         
             
            	EM_eUnsupported = rb_define_class_under (EmModule, "Unsupported", rb_eRuntimeError);
         
     | 
| 
      
 1398 
     | 
    
         
            +
            	EM_eInvalidSignature = rb_define_class_under (EmModule, "InvalidSignature", rb_eRuntimeError);
         
     | 
| 
       1392 
1399 
     | 
    
         | 
| 
       1393 
1400 
     | 
    
         
             
            	rb_define_module_function (EmModule, "initialize_event_machine", (VALUE(*)(...))t_initialize_event_machine, 0);
         
     | 
| 
       1394 
1401 
     | 
    
         
             
            	rb_define_module_function (EmModule, "run_machine_once", (VALUE(*)(...))t_run_machine_once, 0);
         
     | 
    
        data/lib/em/version.rb
    CHANGED
    
    
    
        data/lib/jeventmachine.rb
    CHANGED
    
    | 
         @@ -226,12 +226,12 @@ module EventMachine 
     | 
|
| 
       226 
226 
     | 
    
         
             
                  field.setAccessible(true)
         
     | 
| 
       227 
227 
     | 
    
         
             
                  fileno = field.get(fileno)
         
     | 
| 
       228 
228 
     | 
    
         
             
                else
         
     | 
| 
       229 
     | 
    
         
            -
                  raise ArgumentError, 'attach_fd requires Java Channel or POSIX fileno' unless fileno.is_a?  
     | 
| 
      
 229 
     | 
    
         
            +
                  raise ArgumentError, 'attach_fd requires Java Channel or POSIX fileno' unless fileno.is_a? Integer
         
     | 
| 
       230 
230 
     | 
    
         
             
                end
         
     | 
| 
       231 
231 
     | 
    
         | 
| 
       232 
232 
     | 
    
         
             
                if fileno == 0
         
     | 
| 
       233 
233 
     | 
    
         
             
                  raise "can't open STDIN as selectable in Java =("
         
     | 
| 
       234 
     | 
    
         
            -
                elsif fileno.is_a?  
     | 
| 
      
 234 
     | 
    
         
            +
                elsif fileno.is_a? Integer
         
     | 
| 
       235 
235 
     | 
    
         
             
                  # 8Aug09: The following code is specific to the sun jvm's SocketChannelImpl. Is there a cross-platform
         
     | 
| 
       236 
236 
     | 
    
         
             
                  # way of implementing this? If so, also remember to update EventableSocketChannel#close and #cleanup
         
     | 
| 
       237 
237 
     | 
    
         
             
                  fd = FileDescriptor.new
         
     | 
    
        data/tests/test_basic.rb
    CHANGED
    
    | 
         @@ -146,7 +146,7 @@ class TestBasic < Test::Unit::TestCase 
     | 
|
| 
       146 
146 
     | 
    
         
             
              def test_bind_connect
         
     | 
| 
       147 
147 
     | 
    
         
             
                pend('FIXME: this test is broken on Windows') if windows?
         
     | 
| 
       148 
148 
     | 
    
         | 
| 
       149 
     | 
    
         
            -
                local_ip = UDPSocket.open {|s| s.connect(' 
     | 
| 
      
 149 
     | 
    
         
            +
                local_ip = UDPSocket.open {|s| s.connect('localhost', 80); s.addr.last }
         
     | 
| 
       150 
150 
     | 
    
         | 
| 
       151 
151 
     | 
    
         
             
                bind_port = next_port
         
     | 
| 
       152 
152 
     | 
    
         | 
| 
         @@ -1,13 +1,42 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'em_test_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            class TestConnectionCount < Test::Unit::TestCase
         
     | 
| 
      
 4 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 5 
     | 
    
         
            +
                EM.epoll = false
         
     | 
| 
      
 6 
     | 
    
         
            +
                EM.kqueue = false
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       4 
9 
     | 
    
         
             
              def test_idle_connection_count
         
     | 
| 
      
 10 
     | 
    
         
            +
                count = nil
         
     | 
| 
       5 
11 
     | 
    
         
             
                EM.run {
         
     | 
| 
       6 
     | 
    
         
            -
                   
     | 
| 
      
 12 
     | 
    
         
            +
                  count = EM.connection_count
         
     | 
| 
       7 
13 
     | 
    
         
             
                  EM.stop_event_loop
         
     | 
| 
       8 
14 
     | 
    
         
             
                }
         
     | 
| 
      
 15 
     | 
    
         
            +
                assert_equal(0, count)
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              # Run this again with epoll enabled (if available)
         
     | 
| 
      
 19 
     | 
    
         
            +
              def test_idle_connection_count_epoll
         
     | 
| 
      
 20 
     | 
    
         
            +
                EM.epoll if EM.epoll?
         
     | 
| 
       9 
21 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
      
 22 
     | 
    
         
            +
                count = nil
         
     | 
| 
      
 23 
     | 
    
         
            +
                EM.run {
         
     | 
| 
      
 24 
     | 
    
         
            +
                  count = EM.connection_count
         
     | 
| 
      
 25 
     | 
    
         
            +
                  EM.stop_event_loop
         
     | 
| 
      
 26 
     | 
    
         
            +
                }
         
     | 
| 
      
 27 
     | 
    
         
            +
                assert_equal(0, count)
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              # Run this again with kqueue enabled (if available)
         
     | 
| 
      
 31 
     | 
    
         
            +
              def test_idle_connection_count_kqueue
         
     | 
| 
      
 32 
     | 
    
         
            +
                EM.kqueue if EM.kqueue?
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                count = nil
         
     | 
| 
      
 35 
     | 
    
         
            +
                EM.run {
         
     | 
| 
      
 36 
     | 
    
         
            +
                  count = EM.connection_count
         
     | 
| 
      
 37 
     | 
    
         
            +
                  EM.stop_event_loop
         
     | 
| 
      
 38 
     | 
    
         
            +
                }
         
     | 
| 
      
 39 
     | 
    
         
            +
                assert_equal(0, count)
         
     | 
| 
       11 
40 
     | 
    
         
             
              end
         
     | 
| 
       12 
41 
     | 
    
         | 
| 
       13 
42 
     | 
    
         
             
              module Client
         
     | 
    
        data/tests/test_file_watch.rb
    CHANGED
    
    | 
         @@ -55,6 +55,25 @@ class TestFileWatch < Test::Unit::TestCase 
     | 
|
| 
       55 
55 
     | 
    
         
             
                  assert($deleted)
         
     | 
| 
       56 
56 
     | 
    
         
             
                  assert($unbind)
         
     | 
| 
       57 
57 
     | 
    
         
             
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                # Refer: https://github.com/eventmachine/eventmachine/issues/512
         
     | 
| 
      
 60 
     | 
    
         
            +
                def test_invalid_signature
         
     | 
| 
      
 61 
     | 
    
         
            +
                  # This works fine with kqueue, only fails with linux inotify.
         
     | 
| 
      
 62 
     | 
    
         
            +
                  omit_if(EM.kqueue?)
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                  EM.run {
         
     | 
| 
      
 65 
     | 
    
         
            +
                    file = Tempfile.new('foo')
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                    w1 = EventMachine.watch_file(file.path)
         
     | 
| 
      
 68 
     | 
    
         
            +
                    w2 = EventMachine.watch_file(file.path)
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                    assert_raise EventMachine::InvalidSignature do
         
     | 
| 
      
 71 
     | 
    
         
            +
                      w2.stop_watching
         
     | 
| 
      
 72 
     | 
    
         
            +
                    end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                    EM.stop
         
     | 
| 
      
 75 
     | 
    
         
            +
                  }
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
       58 
77 
     | 
    
         
             
              else
         
     | 
| 
       59 
78 
     | 
    
         
             
                warn "EM.watch_file not implemented, skipping tests in #{__FILE__}"
         
     | 
| 
       60 
79 
     | 
    
         | 
    
        data/tests/test_httpclient.rb
    CHANGED
    
    | 
         @@ -2,13 +2,8 @@ require 'em_test_helper' 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            class TestHttpClient < Test::Unit::TestCase
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
                Localhost = "127.0.0.1"
         
     | 
| 
       6 
     | 
    
         
            -
                Localport = 9801
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
5 
     | 
    
         
             
              def setup
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              def teardown
         
     | 
| 
      
 6 
     | 
    
         
            +
                @port = next_port
         
     | 
| 
       12 
7 
     | 
    
         
             
              end
         
     | 
| 
       13 
8 
     | 
    
         | 
| 
       14 
9 
     | 
    
         
             
              #-------------------------------------
         
     | 
| 
         @@ -19,6 +14,7 @@ class TestHttpClient < Test::Unit::TestCase 
     | 
|
| 
       19 
14 
     | 
    
         
             
                  c = silent { EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80 }
         
     | 
| 
       20 
15 
     | 
    
         
             
                  c.callback {
         
     | 
| 
       21 
16 
     | 
    
         
             
                    ok = true
         
     | 
| 
      
 17 
     | 
    
         
            +
                    c.close_connection
         
     | 
| 
       22 
18 
     | 
    
         
             
                    EM.stop
         
     | 
| 
       23 
19 
     | 
    
         
             
                  }
         
     | 
| 
       24 
20 
     | 
    
         
             
                  c.errback {EM.stop} # necessary, otherwise a failure blocks the test suite forever.
         
     | 
| 
         @@ -32,7 +28,11 @@ class TestHttpClient < Test::Unit::TestCase 
     | 
|
| 
       32 
28 
     | 
    
         
             
                ok = false
         
     | 
| 
       33 
29 
     | 
    
         
             
                EM.run {
         
     | 
| 
       34 
30 
     | 
    
         
             
                  c = silent { EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80 }
         
     | 
| 
       35 
     | 
    
         
            -
                  c.callback { 
     | 
| 
      
 31 
     | 
    
         
            +
                  c.callback {
         
     | 
| 
      
 32 
     | 
    
         
            +
                    ok = true
         
     | 
| 
      
 33 
     | 
    
         
            +
                    c.close_connection
         
     | 
| 
      
 34 
     | 
    
         
            +
                    EM.stop
         
     | 
| 
      
 35 
     | 
    
         
            +
                  }
         
     | 
| 
       36 
36 
     | 
    
         
             
                  c.errback {EM.stop}
         
     | 
| 
       37 
37 
     | 
    
         
             
                }
         
     | 
| 
       38 
38 
     | 
    
         
             
                assert ok
         
     | 
| 
         @@ -44,8 +44,9 @@ class TestHttpClient < Test::Unit::TestCase 
     | 
|
| 
       44 
44 
     | 
    
         
             
                ok = false
         
     | 
| 
       45 
45 
     | 
    
         
             
                EM.run {
         
     | 
| 
       46 
46 
     | 
    
         
             
                  c = silent { EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80 }
         
     | 
| 
       47 
     | 
    
         
            -
                  c.callback { 
     | 
| 
       48 
     | 
    
         
            -
                    ok = true 
     | 
| 
      
 47 
     | 
    
         
            +
                  c.callback {
         
     | 
| 
      
 48 
     | 
    
         
            +
                    ok = true
         
     | 
| 
      
 49 
     | 
    
         
            +
                    c.close_connection
         
     | 
| 
       49 
50 
     | 
    
         
             
                    EM.stop
         
     | 
| 
       50 
51 
     | 
    
         
             
                  }
         
     | 
| 
       51 
52 
     | 
    
         
             
                  c.errback {EM.stop}
         
     | 
| 
         @@ -74,10 +75,11 @@ class TestHttpClient < Test::Unit::TestCase 
     | 
|
| 
       74 
75 
     | 
    
         
             
              def test_http_empty_content
         
     | 
| 
       75 
76 
     | 
    
         
             
                  ok = false
         
     | 
| 
       76 
77 
     | 
    
         
             
                  EM.run {
         
     | 
| 
       77 
     | 
    
         
            -
                    EM.start_server "127.0.0.1",  
     | 
| 
       78 
     | 
    
         
            -
                    c = silent { EM::P::HttpClient.send :request, :host => "127.0.0.1", :port =>  
     | 
| 
       79 
     | 
    
         
            -
                    c.callback { 
     | 
| 
      
 78 
     | 
    
         
            +
                    EM.start_server "127.0.0.1", @port, EmptyContent
         
     | 
| 
      
 79 
     | 
    
         
            +
                    c = silent { EM::P::HttpClient.send :request, :host => "127.0.0.1", :port => @port }
         
     | 
| 
      
 80 
     | 
    
         
            +
                    c.callback {
         
     | 
| 
       80 
81 
     | 
    
         
             
                      ok = true
         
     | 
| 
      
 82 
     | 
    
         
            +
                      c.close_connection
         
     | 
| 
       81 
83 
     | 
    
         
             
                      EM.stop
         
     | 
| 
       82 
84 
     | 
    
         
             
                    }
         
     | 
| 
       83 
85 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -132,15 +134,15 @@ class TestHttpClient < Test::Unit::TestCase 
     | 
|
| 
       132 
134 
     | 
    
         
             
              def test_post
         
     | 
| 
       133 
135 
     | 
    
         
             
                  response = nil
         
     | 
| 
       134 
136 
     | 
    
         
             
                  EM.run {
         
     | 
| 
       135 
     | 
    
         
            -
                    EM.start_server  
     | 
| 
      
 137 
     | 
    
         
            +
                    EM.start_server '127.0.0.1', @port, PostContent
         
     | 
| 
       136 
138 
     | 
    
         
             
                    setup_timeout(2)
         
     | 
| 
       137 
139 
     | 
    
         
             
                    c = silent { EM::P::HttpClient.request(
         
     | 
| 
       138 
     | 
    
         
            -
                      :host=> 
     | 
| 
       139 
     | 
    
         
            -
                      :port=> 
     | 
| 
       140 
     | 
    
         
            -
                      :method 
     | 
| 
       141 
     | 
    
         
            -
                      :request=>"/aaa",
         
     | 
| 
       142 
     | 
    
         
            -
                      :content=>"XYZ",
         
     | 
| 
       143 
     | 
    
         
            -
                      :content_type=>"text/plain"
         
     | 
| 
      
 140 
     | 
    
         
            +
                      :host         => '127.0.0.1',
         
     | 
| 
      
 141 
     | 
    
         
            +
                      :port         => @port,
         
     | 
| 
      
 142 
     | 
    
         
            +
                      :method       => :post,
         
     | 
| 
      
 143 
     | 
    
         
            +
                      :request      => "/aaa",
         
     | 
| 
      
 144 
     | 
    
         
            +
                      :content      => "XYZ",
         
     | 
| 
      
 145 
     | 
    
         
            +
                      :content_type => "text/plain"
         
     | 
| 
       144 
146 
     | 
    
         
             
                    )}
         
     | 
| 
       145 
147 
     | 
    
         
             
                    c.callback {|r|
         
     | 
| 
       146 
148 
     | 
    
         
             
                      response = r
         
     | 
| 
         @@ -159,8 +161,9 @@ class TestHttpClient < Test::Unit::TestCase 
     | 
|
| 
       159 
161 
     | 
    
         
             
                ok = false
         
     | 
| 
       160 
162 
     | 
    
         
             
                EM.run {
         
     | 
| 
       161 
163 
     | 
    
         
             
                  c = silent { EM::Protocols::HttpClient.send :request, :host => "www.google.com", :port => 80, :cookie=>"aaa=bbb" }
         
     | 
| 
       162 
     | 
    
         
            -
                  c.callback { 
     | 
| 
       163 
     | 
    
         
            -
                    ok = true 
     | 
| 
      
 164 
     | 
    
         
            +
                  c.callback {
         
     | 
| 
      
 165 
     | 
    
         
            +
                    ok = true
         
     | 
| 
      
 166 
     | 
    
         
            +
                    c.close_connection
         
     | 
| 
       164 
167 
     | 
    
         
             
                    EM.stop
         
     | 
| 
       165 
168 
     | 
    
         
             
                  }
         
     | 
| 
       166 
169 
     | 
    
         
             
                  c.errback {EM.stop}
         
     | 
| 
         @@ -178,8 +181,9 @@ class TestHttpClient < Test::Unit::TestCase 
     | 
|
| 
       178 
181 
     | 
    
         
             
                    :port => 80,
         
     | 
| 
       179 
182 
     | 
    
         
             
                    :version => "1.0"
         
     | 
| 
       180 
183 
     | 
    
         
             
                  )}
         
     | 
| 
       181 
     | 
    
         
            -
                  c.callback { 
     | 
| 
       182 
     | 
    
         
            -
                    ok = true 
     | 
| 
      
 184 
     | 
    
         
            +
                  c.callback {
         
     | 
| 
      
 185 
     | 
    
         
            +
                    ok = true
         
     | 
| 
      
 186 
     | 
    
         
            +
                    c.close_connection
         
     | 
| 
       183 
187 
     | 
    
         
             
                    EM.stop
         
     | 
| 
       184 
188 
     | 
    
         
             
                  }
         
     | 
| 
       185 
189 
     | 
    
         
             
                  c.errback {EM.stop}
         
     | 
| 
         @@ -215,14 +219,15 @@ class TestHttpClient < Test::Unit::TestCase 
     | 
|
| 
       215 
219 
     | 
    
         | 
| 
       216 
220 
     | 
    
         
             
              def test_http_chunked_encoding_content
         
     | 
| 
       217 
221 
     | 
    
         
             
                ok = false
         
     | 
| 
       218 
     | 
    
         
            -
                 
     | 
| 
       219 
     | 
    
         
            -
                   
     | 
| 
       220 
     | 
    
         
            -
                  c =  
     | 
| 
       221 
     | 
    
         
            -
                  c.callback {|result|
         
     | 
| 
      
 222 
     | 
    
         
            +
                EM.run {
         
     | 
| 
      
 223 
     | 
    
         
            +
                  EM.start_server "127.0.0.1", @port, ChunkedEncodingContent
         
     | 
| 
      
 224 
     | 
    
         
            +
                  c = silent { EM::P::HttpClient.send :request, :host => "127.0.0.1", :port => @port }
         
     | 
| 
      
 225 
     | 
    
         
            +
                  c.callback { |result|
         
     | 
| 
       222 
226 
     | 
    
         
             
                    if result[:content] == "chunk1" * 1024 + "chunk2" * 15
         
     | 
| 
       223 
227 
     | 
    
         
             
                      ok = true
         
     | 
| 
       224 
228 
     | 
    
         
             
                    end
         
     | 
| 
       225 
     | 
    
         
            -
                     
     | 
| 
      
 229 
     | 
    
         
            +
                    c.close_connection
         
     | 
| 
      
 230 
     | 
    
         
            +
                    EM.stop
         
     | 
| 
       226 
231 
     | 
    
         
             
                  }
         
     | 
| 
       227 
232 
     | 
    
         
             
                }
         
     | 
| 
       228 
233 
     | 
    
         
             
                assert ok
         
     | 
    
        data/tests/test_httpclient2.rb
    CHANGED
    
    | 
         @@ -1,17 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'em_test_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            class TestHttpClient2 < Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
              Localport = 9801
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              def setup
         
     | 
| 
       8 
     | 
    
         
            -
              end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              def teardown
         
     | 
| 
      
 4 
     | 
    
         
            +
              class TestServer < EM::Connection
         
     | 
| 
       11 
5 
     | 
    
         
             
              end
         
     | 
| 
       12 
6 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 8 
     | 
    
         
            +
                @port = next_port
         
     | 
| 
       15 
9 
     | 
    
         
             
              end
         
     | 
| 
       16 
10 
     | 
    
         | 
| 
       17 
11 
     | 
    
         
             
              # #connect returns an object which has made a connection to an HTTP server
         
     | 
| 
         @@ -21,21 +15,22 @@ class TestHttpClient2 < Test::Unit::TestCase 
     | 
|
| 
       21 
15 
     | 
    
         
             
              #
         
     | 
| 
       22 
16 
     | 
    
         
             
              def test_connect
         
     | 
| 
       23 
17 
     | 
    
         
             
                EM.run {
         
     | 
| 
       24 
     | 
    
         
            -
                   
     | 
| 
      
 18 
     | 
    
         
            +
                  setup_timeout(1)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  EM.start_server '127.0.0.1', @port, TestServer
         
     | 
| 
       25 
20 
     | 
    
         
             
                  silent do
         
     | 
| 
       26 
     | 
    
         
            -
                    EM::P::HttpClient2.connect  
     | 
| 
       27 
     | 
    
         
            -
                    EM::P::HttpClient2.connect( :host=> 
     | 
| 
      
 21 
     | 
    
         
            +
                    EM::P::HttpClient2.connect '127.0.0.1', @port
         
     | 
| 
      
 22 
     | 
    
         
            +
                    EM::P::HttpClient2.connect( :host=>'127.0.0.1', :port=>@port )
         
     | 
| 
       28 
23 
     | 
    
         
             
                  end
         
     | 
| 
       29 
24 
     | 
    
         
             
                  EM.stop
         
     | 
| 
       30 
25 
     | 
    
         
             
                }
         
     | 
| 
       31 
26 
     | 
    
         
             
              end
         
     | 
| 
       32 
27 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
28 
     | 
    
         
             
              def test_bad_port
         
     | 
| 
       35 
29 
     | 
    
         
             
                EM.run {
         
     | 
| 
       36 
     | 
    
         
            -
                   
     | 
| 
      
 30 
     | 
    
         
            +
                  setup_timeout(1)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  EM.start_server '127.0.0.1', @port, TestServer
         
     | 
| 
       37 
32 
     | 
    
         
             
                  assert_raises( ArgumentError ) {
         
     | 
| 
       38 
     | 
    
         
            -
                    silent { EM::P::HttpClient2.connect  
     | 
| 
      
 33 
     | 
    
         
            +
                    silent { EM::P::HttpClient2.connect '127.0.0.1', "xxx" }
         
     | 
| 
       39 
34 
     | 
    
         
             
                  }
         
     | 
| 
       40 
35 
     | 
    
         
             
                  EM.stop
         
     | 
| 
       41 
36 
     | 
    
         
             
                }
         
     | 
| 
         @@ -44,7 +39,8 @@ class TestHttpClient2 < Test::Unit::TestCase 
     | 
|
| 
       44 
39 
     | 
    
         
             
              def test_bad_server
         
     | 
| 
       45 
40 
     | 
    
         
             
                err = nil
         
     | 
| 
       46 
41 
     | 
    
         
             
                EM.run {
         
     | 
| 
       47 
     | 
    
         
            -
                   
     | 
| 
      
 42 
     | 
    
         
            +
                  setup_timeout(1)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  http = silent { EM::P::HttpClient2.connect '127.0.0.1', 9999 }
         
     | 
| 
       48 
44 
     | 
    
         
             
                  d = http.get "/"
         
     | 
| 
       49 
45 
     | 
    
         
             
                  d.errback { err = true; d.internal_error; EM.stop }
         
     | 
| 
       50 
46 
     | 
    
         
             
                }
         
     | 
| 
         @@ -54,7 +50,8 @@ class TestHttpClient2 < Test::Unit::TestCase 
     | 
|
| 
       54 
50 
     | 
    
         
             
              def test_get
         
     | 
| 
       55 
51 
     | 
    
         
             
                content = nil
         
     | 
| 
       56 
52 
     | 
    
         
             
                EM.run {
         
     | 
| 
       57 
     | 
    
         
            -
                   
     | 
| 
      
 53 
     | 
    
         
            +
                  setup_timeout(1)
         
     | 
| 
      
 54 
     | 
    
         
            +
                  http = silent { EM::P::HttpClient2.connect :host => "google.com", :port => 80, :version => '1.0' }
         
     | 
| 
       58 
55 
     | 
    
         
             
                  d = http.get "/"
         
     | 
| 
       59 
56 
     | 
    
         
             
                  d.callback {
         
     | 
| 
       60 
57 
     | 
    
         
             
                    content = d.content
         
     | 
| 
         @@ -70,7 +67,8 @@ class TestHttpClient2 < Test::Unit::TestCase 
     | 
|
| 
       70 
67 
     | 
    
         
             
              def _test_get_multiple
         
     | 
| 
       71 
68 
     | 
    
         
             
                content = nil
         
     | 
| 
       72 
69 
     | 
    
         
             
                EM.run {
         
     | 
| 
       73 
     | 
    
         
            -
                   
     | 
| 
      
 70 
     | 
    
         
            +
                  setup_timeout(1)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  http = silent { EM::P::HttpClient2.connect "google.com", :version => '1.0' }
         
     | 
| 
       74 
72 
     | 
    
         
             
                  d = http.get "/"
         
     | 
| 
       75 
73 
     | 
    
         
             
                  d.callback {
         
     | 
| 
       76 
74 
     | 
    
         
             
                    e = http.get "/"
         
     | 
| 
         @@ -86,6 +84,7 @@ class TestHttpClient2 < Test::Unit::TestCase 
     | 
|
| 
       86 
84 
     | 
    
         
             
              def test_get_pipeline
         
     | 
| 
       87 
85 
     | 
    
         
             
                headers, headers2 = nil, nil
         
     | 
| 
       88 
86 
     | 
    
         
             
                EM.run {
         
     | 
| 
      
 87 
     | 
    
         
            +
                  setup_timeout(1)
         
     | 
| 
       89 
88 
     | 
    
         
             
                  http = silent { EM::P::HttpClient2.connect "google.com", 80 }
         
     | 
| 
       90 
89 
     | 
    
         
             
                  d = http.get("/")
         
     | 
| 
       91 
90 
     | 
    
         
             
                  d.callback {
         
     | 
| 
         @@ -102,11 +101,11 @@ class TestHttpClient2 < Test::Unit::TestCase 
     | 
|
| 
       102 
101 
     | 
    
         
             
                assert(headers2)
         
     | 
| 
       103 
102 
     | 
    
         
             
              end
         
     | 
| 
       104 
103 
     | 
    
         | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
104 
     | 
    
         
             
              def test_authheader
         
     | 
| 
       107 
105 
     | 
    
         
             
                EM.run {
         
     | 
| 
       108 
     | 
    
         
            -
                   
     | 
| 
       109 
     | 
    
         
            -
                   
     | 
| 
      
 106 
     | 
    
         
            +
                  setup_timeout(1)
         
     | 
| 
      
 107 
     | 
    
         
            +
                  EM.start_server '127.0.0.1', @port, TestServer
         
     | 
| 
      
 108 
     | 
    
         
            +
                  http = silent { EM::P::HttpClient2.connect '127.0.0.1', 18842 }
         
     | 
| 
       110 
109 
     | 
    
         
             
                  d = http.get :url=>"/", :authorization=>"Basic xxx"
         
     | 
| 
       111 
110 
     | 
    
         
             
                  d.callback {EM.stop}
         
     | 
| 
       112 
111 
     | 
    
         
             
                  d.errback {EM.stop}
         
     | 
| 
         @@ -114,15 +113,16 @@ class TestHttpClient2 < Test::Unit::TestCase 
     | 
|
| 
       114 
113 
     | 
    
         
             
              end
         
     | 
| 
       115 
114 
     | 
    
         | 
| 
       116 
115 
     | 
    
         
             
              def test_https_get
         
     | 
| 
      
 116 
     | 
    
         
            +
                omit_unless(EM.ssl?)
         
     | 
| 
       117 
117 
     | 
    
         
             
                d = nil
         
     | 
| 
       118 
118 
     | 
    
         
             
                EM.run {
         
     | 
| 
       119 
     | 
    
         
            -
                   
     | 
| 
      
 119 
     | 
    
         
            +
                  setup_timeout(1)
         
     | 
| 
      
 120 
     | 
    
         
            +
                  http = silent { EM::P::HttpClient2.connect :host => 'www.google.com', :port => 443, :ssl => true, :version => '1.0' }
         
     | 
| 
       120 
121 
     | 
    
         
             
                  d = http.get "/"
         
     | 
| 
       121 
     | 
    
         
            -
                  d.callback {
         
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
                  }
         
     | 
| 
      
 122 
     | 
    
         
            +
                  d.callback {EM.stop}
         
     | 
| 
      
 123 
     | 
    
         
            +
                  d.errback {EM.stop}
         
     | 
| 
       124 
124 
     | 
    
         
             
                }
         
     | 
| 
       125 
125 
     | 
    
         
             
                assert_equal(200, d.status)
         
     | 
| 
       126 
     | 
    
         
            -
              end 
     | 
| 
      
 126 
     | 
    
         
            +
              end
         
     | 
| 
       127 
127 
     | 
    
         | 
| 
       128 
128 
     | 
    
         
             
            end
         
     |