excon 0.45.1 → 0.45.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of excon might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcb3c2e59bcdc04bc44b0f35f0980c867bbbf473
4
- data.tar.gz: c44d0ea79c4cd3e68b3170ac995f70d71705c6db
3
+ metadata.gz: 8fdb02fc261d826e83a7b33488486b4a3236c609
4
+ data.tar.gz: 921e5479f0beffa9487cb7d8d518e42f12d8acb5
5
5
  SHA512:
6
- metadata.gz: 424698e41e10a91c88385de9bfc8858add4232dd341ec22122095fb657ab88d4fac181320e69525e0e9ddbedcb835697359d1a88e0aacfc0fb024b479c1fe956
7
- data.tar.gz: 8c25c646e3a66aa51bc49029c0bb0b52b2bb0878e85d9143c03261a3ba42684fd0fcfaf4df8b053d8b16146e473c331e4a744ad5314c61062354d55ca0fe3839
6
+ metadata.gz: 1aa150b70ac25a38a6b2c862054ae680d406b40f685ca767a792ef2d35522ec856aacd8d56aa344cd18e13d91c563ae737d1d3e2d4ff11ef4328639a0e4dfe9c
7
+ data.tar.gz: 00b918d4dc23c27b0fb9871125be50e6ae51460a6517db29b85af86216e76d5c0c49db6a8b1a3820dc4221116cc2efd884c64bae594117e204eb0ba85ed67ef8
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- excon (0.45.1)
4
+ excon (0.45.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,3 +1,13 @@
1
+ 0.45.2 04/16/2015
2
+ =================
3
+
4
+ add raw_status reader
5
+ improved tests around response/status
6
+ rescue IO::WaitWritable for SSL sockets also
7
+ indentation fixes
8
+ tighten rescue in ssl socket connect to better report non-timeouts
9
+ rescue EAGAIN and EWOULDBLOCK for non-blocking connects
10
+
1
11
  0.45.1 03/27/2015
2
12
  =================
3
13
 
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'excon'
16
- s.version = '0.45.1'
17
- s.date = '2015-03-27'
16
+ s.version = '0.45.2'
17
+ s.date = '2015-04-16'
18
18
  s.rubyforge_project = 'excon'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -122,6 +122,7 @@ Gem::Specification.new do |s|
122
122
  tests/authorization_header_tests.rb
123
123
  tests/bad_tests.rb
124
124
  tests/basic_tests.rb
125
+ tests/complete_responses.rb
125
126
  tests/data/127.0.0.1.cert.crt
126
127
  tests/data/127.0.0.1.cert.key
127
128
  tests/data/excon.cert.crt
@@ -1,6 +1,6 @@
1
1
  module Excon
2
2
 
3
- VERSION = '0.45.1'
3
+ VERSION = '0.45.2'
4
4
 
5
5
  CR_NL = "\r\n"
6
6
 
@@ -22,6 +22,12 @@ module Excon
22
22
  def status
23
23
  @data[:status]
24
24
  end
25
+ def status_line
26
+ @data[:status_line]
27
+ end
28
+ def status_line=(new_status_line)
29
+ @data[:status_line] = new_status_line
30
+ end
25
31
  def reason_phrase=(new_reason_phrase)
26
32
  @data[:reason_phrase] = new_reason_phrase
27
33
  end
@@ -53,6 +59,7 @@ module Excon
53
59
  :body => '',
54
60
  :headers => Excon::Headers.new,
55
61
  :status => status,
62
+ :status_line => line,
56
63
  :reason_phrase => reason_phrase
57
64
  }
58
65
 
@@ -64,12 +64,12 @@ module Excon
64
64
  end
65
65
 
66
66
  def legacy_readline
67
- begin
67
+ begin
68
68
  Timeout.timeout(@data[:read_timeout]) do
69
69
  @socket.readline
70
- end
70
+ end
71
71
  rescue Timeout::Error
72
- raise Excon::Errors::Timeout.new('read timeout reached')
72
+ raise Excon::Errors::Timeout.new('read timeout reached')
73
73
  end
74
74
  end
75
75
 
@@ -163,37 +163,37 @@ module Excon
163
163
 
164
164
  def read_nonblock(max_length)
165
165
  begin
166
- if max_length
167
- until @read_buffer.length >= max_length
168
- @read_buffer << @socket.read_nonblock(max_length - @read_buffer.length)
169
- end
170
- else
171
- loop do
172
- @read_buffer << @socket.read_nonblock(@data[:chunk_size])
173
- end
174
- end
175
- rescue OpenSSL::SSL::SSLError => error
176
- if error.message == 'read would block'
177
- if timeout_reached('read')
178
- raise_timeout_error('read')
179
- else
180
- retry
181
- end
182
- else
183
- raise(error)
184
- end
185
- rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
186
- if @read_buffer.empty?
187
- # if we didn't read anything, try again...
188
- if timeout_reached('read')
189
- raise_timeout_error('read')
190
- else
191
- retry
192
- end
193
- end
194
- rescue EOFError
195
- @eof = true
166
+ if max_length
167
+ until @read_buffer.length >= max_length
168
+ @read_buffer << @socket.read_nonblock(max_length - @read_buffer.length)
169
+ end
170
+ else
171
+ loop do
172
+ @read_buffer << @socket.read_nonblock(@data[:chunk_size])
173
+ end
174
+ end
175
+ rescue OpenSSL::SSL::SSLError => error
176
+ if error.message == 'read would block'
177
+ if timeout_reached('read')
178
+ raise_timeout_error('read')
179
+ else
180
+ retry
196
181
  end
182
+ else
183
+ raise(error)
184
+ end
185
+ rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
186
+ if @read_buffer.empty?
187
+ # if we didn't read anything, try again...
188
+ if timeout_reached('read')
189
+ raise_timeout_error('read')
190
+ else
191
+ retry
192
+ end
193
+ end
194
+ rescue EOFError
195
+ @eof = true
196
+ end
197
197
 
198
198
  if max_length
199
199
  if @read_buffer.empty?
@@ -234,7 +234,7 @@ module Excon
234
234
  def write_nonblock(data)
235
235
  if FORCE_ENC
236
236
  data.force_encoding('BINARY')
237
- end
237
+ end
238
238
  loop do
239
239
  written = nil
240
240
  begin
@@ -118,16 +118,17 @@ module Excon
118
118
  if @nonblock
119
119
  begin
120
120
  @socket.connect_nonblock
121
- rescue IO::WaitReadable
121
+ rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
122
122
  IO.select([@socket])
123
123
  retry
124
+ rescue IO::WaitWritable
125
+ IO.select(nil, [@socket])
126
+ retry
124
127
  end
125
128
  else
126
129
  @socket.connect
127
130
  end
128
- rescue OpenSSL::SSL::SSLError
129
- raise
130
- rescue
131
+ rescue Errno::ETIMEDOUT, Timeout::Error
131
132
  raise Excon::Errors::Timeout.new('connect timeout reached')
132
133
  end
133
134
 
@@ -0,0 +1,31 @@
1
+ Shindo.tests('Excon Response Validation') do
2
+ env_init
3
+
4
+ with_server('good') do
5
+ tests('good responses with complete headers') do
6
+ 100.times do
7
+ res = Excon.get('http://127.0.0.1:9292/chunked/simple')
8
+ returns(true) { res.body == "hello world" }
9
+ returns(true) { res.status_line == "HTTP/1.1 200 OK\r\n" }
10
+ returns(true) { res.status == 200}
11
+ returns(true) { res.reason_phrase == "OK" }
12
+ returns(true) { res.remote_ip == "127.0.0.1" }
13
+ end
14
+ end
15
+ end
16
+
17
+ with_server('error') do
18
+ tests('error responses with complete headers') do
19
+ 100.times do
20
+ res = Excon.get('http://127.0.0.1:9292/error/not_found')
21
+ returns(true) { res.body == "server says not found" }
22
+ returns(true) { res.status_line == "HTTP/1.1 404 Not Found\r\n" }
23
+ returns(true) { res.status == 404}
24
+ returns(true) { res.reason_phrase == "Not Found" }
25
+ returns(true) { res.remote_ip == "127.0.0.1" }
26
+ end
27
+ end
28
+ end
29
+
30
+ env_restore
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.45.1
4
+ version: 0.45.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - dpiddy (Dan Peterson)
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-03-27 00:00:00.000000000 Z
13
+ date: 2015-04-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -198,6 +198,7 @@ files:
198
198
  - tests/authorization_header_tests.rb
199
199
  - tests/bad_tests.rb
200
200
  - tests/basic_tests.rb
201
+ - tests/complete_responses.rb
201
202
  - tests/data/127.0.0.1.cert.crt
202
203
  - tests/data/127.0.0.1.cert.key
203
204
  - tests/data/excon.cert.crt