http 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9ab434cda0513a1deb802c3eb66532ad897ef13
4
- data.tar.gz: 4a5ee3cdd9658e59103c4199d9cb188373118328
3
+ metadata.gz: c1272220e79324fa76789c67d151606fa0dbcfc7
4
+ data.tar.gz: f230afedc0fe89d4c1d5e6ed085d9be2175ef18f
5
5
  SHA512:
6
- metadata.gz: c91c74059544ed2f6435bfce620b1720453451419a6a948880043abab4883f5176d32c92d9f59ed86199dff1df1a781d01c876817f7d8312918dc21f338846aa
7
- data.tar.gz: ba055614610f7fe562ed53c8ea87e350a74459ebcfa38dcf7ec28b2d8c3bd8d1f6581bda7345853087d573218e174813d21b449c69d5c9ace94b6dfa640d089a
6
+ metadata.gz: 1a39842cb85a6cc17c7d4c98cda9eb66f381388640f60bca7eb706029efac93a3c2477ea0ead3059fe878db61bdc2c561a68aa735b8920784caff1baa3008f70
7
+ data.tar.gz: c2009ff6fc49726815f0ff0860b91b77b626a02845ba534dd04e3466971ee4cc2d5926c8e4a966ed802d7e789e264eb2a104e1fc0f49e3e2a37472a0d8ac9952
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.9.7 (2015-09-19)
2
+
3
+ * Unified strategy for handling exception-based and exceptionless non-blocking
4
+ I/O. Fixes SSL support on JRuby 9000. See #258. (@tonyarcieri)
5
+
1
6
  ## 0.9.6 (2015-09-06)
2
7
 
3
8
  * Removed use of an ActiveSupport specific method #present?
data/Rakefile CHANGED
@@ -23,7 +23,7 @@ end
23
23
  require "yardstick/rake/verify"
24
24
  Yardstick::Rake::Verify.new do |verify|
25
25
  verify.require_exact_threshold = false
26
- verify.threshold = 58
26
+ verify.threshold = 55
27
27
  end
28
28
 
29
29
  task :generate_status_codes do
@@ -39,75 +39,77 @@ module HTTP
39
39
  end
40
40
  end
41
41
 
42
- # NIO with exceptions
42
+ # Read from the socket
43
+ def readpartial(size)
44
+ perform_io { read_nonblock(size) }
45
+ end
46
+
47
+ # Write to the socket
48
+ def write(data)
49
+ perform_io { write_nonblock(data) }
50
+ end
51
+
52
+ alias_method :<<, :write
53
+
54
+ private
55
+
43
56
  if RUBY_VERSION < "2.1.0"
44
- # Read from the socket
45
- def readpartial(size)
46
- reset_timer
47
57
 
48
- begin
49
- socket.read_nonblock(size)
50
- rescue IO::WaitReadable
51
- IO.select([socket], nil, nil, time_left)
52
- log_time
53
- retry
54
- end
55
- rescue EOFError
56
- :eof
58
+ def read_nonblock(size)
59
+ @socket.read_nonblock(size)
57
60
  end
58
61
 
59
- # Write to the socket
60
- def write(data)
61
- reset_timer
62
-
63
- begin
64
- return socket.write_nonblock(data)
65
- rescue IO::WaitWritable
66
- IO.select(nil, [socket], nil, time_left)
67
- log_time
68
- retry
69
- end
70
- rescue EOFError
71
- :eof
62
+ def write_nonblock(data)
63
+ @socket.write_nonblock(data)
72
64
  end
73
65
 
74
- # NIO without exceptions
75
66
  else
76
67
 
77
- # Read from the socket
78
- def readpartial(size)
79
- reset_timer
80
-
81
- loop do
82
- result = socket.read_nonblock(size, :exception => false)
83
- if result.nil?
84
- return :eof
85
- elsif result != :wait_readable
86
- return result
87
- end
68
+ def read_nonblock(size)
69
+ @socket.read_nonblock(size, :exception => false)
70
+ end
88
71
 
89
- IO.select([socket], nil, nil, time_left)
90
- log_time
91
- end
72
+ def write_nonblock(data)
73
+ @socket.write_nonblock(data, :exception => false)
92
74
  end
93
75
 
94
- # Write to the socket
95
- def write(data)
96
- reset_timer
76
+ end
77
+
78
+ # Perform the given I/O operation with the given argument
79
+ def perform_io
80
+ reset_timer
97
81
 
98
- loop do
99
- result = socket.write_nonblock(data, :exception => false)
100
- return result unless result == :wait_writable
82
+ loop do
83
+ begin
84
+ result = yield
101
85
 
102
- IO.select(nil, [socket], nil, time_left)
103
- log_time
86
+ case result
87
+ when :wait_readable then wait_readable_or_timeout
88
+ when :wait_writable then wait_writable_or_timeout
89
+ when NilClass then return :eof
90
+ else return result
91
+ end
92
+ rescue IO::WaitReadable
93
+ wait_readable_or_timeout
94
+ rescue IO::WaitWritable
95
+ wait_writable_or_timeout
104
96
  end
105
97
  end
98
+ rescue EOFError
99
+ :eof
106
100
  end
107
101
 
108
- alias_method :<<, :write
102
+ # Wait for a socket to become readable
103
+ def wait_readable_or_timeout
104
+ IO.select([@socket], nil, nil, time_left)
105
+ log_time
106
+ end
109
107
 
110
- private
108
+ # Wait for a socket to become writable
109
+ def wait_writable_or_timeout
110
+ IO.select(nil, [@socket], nil, time_left)
111
+ log_time
112
+ end
111
113
 
112
114
  # Due to the run/retry nature of nonblocking I/O, it's easier to keep track of time
113
115
  # via method calls instead of a block to monitor.
@@ -1,3 +1,3 @@
1
1
  module HTTP
2
- VERSION = "0.9.6".freeze
2
+ VERSION = "0.9.7".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-09-07 00:00:00.000000000 Z
14
+ date: 2015-09-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: http_parser.rb