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 +4 -4
- data/CHANGES.md +5 -0
- data/Rakefile +1 -1
- data/lib/http/timeout/global.rb +53 -51
- data/lib/http/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1272220e79324fa76789c67d151606fa0dbcfc7
|
4
|
+
data.tar.gz: f230afedc0fe89d4c1d5e6ed085d9be2175ef18f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a39842cb85a6cc17c7d4c98cda9eb66f381388640f60bca7eb706029efac93a3c2477ea0ead3059fe878db61bdc2c561a68aa735b8920784caff1baa3008f70
|
7
|
+
data.tar.gz: c2009ff6fc49726815f0ff0860b91b77b626a02845ba534dd04e3466971ee4cc2d5926c8e4a966ed802d7e789e264eb2a104e1fc0f49e3e2a37472a0d8ac9952
|
data/CHANGES.md
CHANGED
data/Rakefile
CHANGED
data/lib/http/timeout/global.rb
CHANGED
@@ -39,75 +39,77 @@ module HTTP
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
#
|
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
|
-
|
49
|
-
|
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
|
-
|
60
|
-
|
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
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
90
|
-
|
91
|
-
end
|
72
|
+
def write_nonblock(data)
|
73
|
+
@socket.write_nonblock(data, :exception => false)
|
92
74
|
end
|
93
75
|
|
94
|
-
|
95
|
-
|
96
|
-
|
76
|
+
end
|
77
|
+
|
78
|
+
# Perform the given I/O operation with the given argument
|
79
|
+
def perform_io
|
80
|
+
reset_timer
|
97
81
|
|
98
|
-
|
99
|
-
|
100
|
-
|
82
|
+
loop do
|
83
|
+
begin
|
84
|
+
result = yield
|
101
85
|
|
102
|
-
|
103
|
-
|
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
|
-
|
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
|
-
|
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.
|
data/lib/http/version.rb
CHANGED
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.
|
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-
|
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
|