excon 0.5.2 → 0.5.3
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.
- data/Gemfile.lock +1 -1
- data/benchmarks/headers_case_sensitivity.rb +83 -0
- data/excon.gemspec +3 -2
- data/lib/excon.rb +1 -1
- data/lib/excon/connection.rb +1 -1
- data/lib/excon/response.rb +17 -16
- metadata +6 -5
data/Gemfile.lock
CHANGED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'stringio'
|
3
|
+
require 'tach'
|
4
|
+
|
5
|
+
def all_match_socket
|
6
|
+
io = StringIO.new
|
7
|
+
io << "Connection: close\n"
|
8
|
+
io << "Content-Length: 000\n"
|
9
|
+
io << "Content-Type: text/html\n"
|
10
|
+
io << "Date: Xxx, 00 Xxx 0000 00:00:00 GMT\n"
|
11
|
+
io << "Server: xxx\n"
|
12
|
+
io << "Transfer-Encoding: chunked\n"
|
13
|
+
io << "\n\n"
|
14
|
+
io.rewind
|
15
|
+
io
|
16
|
+
end
|
17
|
+
|
18
|
+
Formatador.display_line('all_match')
|
19
|
+
Formatador.indent do
|
20
|
+
Tach.meter(10_000) do
|
21
|
+
tach('compare on read') do
|
22
|
+
socket, headers = all_match_socket, {}
|
23
|
+
until ((data = socket.readline).chop!).empty?
|
24
|
+
key, value = data.split(': ')
|
25
|
+
headers[key] = value
|
26
|
+
(key.casecmp('Transfer-Encoding') == 0) && (value.casecmp('chunked') == 0)
|
27
|
+
(key.casecmp('Connection') == 0) && (value.casecmp('close') == 0)
|
28
|
+
(key.casecmp('Content-Length') == 0)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
tach('original') do
|
33
|
+
socket, headers = all_match_socket, {}
|
34
|
+
until ((data = socket.readline).chop!).empty?
|
35
|
+
key, value = data.split(': ')
|
36
|
+
headers[key] = value
|
37
|
+
end
|
38
|
+
headers.has_key?('Transfer-Encoding') && headers['Transfer-Encoding'].casecmp('chunked') == 0
|
39
|
+
headers.has_key?('Connection') && headers['Connection'].casecmp('close') == 0
|
40
|
+
headers.has_key?('Content-Length')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def none_match_socket
|
46
|
+
io = StringIO.new
|
47
|
+
io << "Cache-Control: max-age=0\n"
|
48
|
+
io << "Content-Type: text/html\n"
|
49
|
+
io << "Date: Xxx, 00 Xxx 0000 00:00:00 GMT\n"
|
50
|
+
io << "Expires: Xxx, 00 Xxx 0000 00:00:00 GMT\n"
|
51
|
+
io << "Last-Modified: Xxx, 00 Xxx 0000 00:00:00 GMT\n"
|
52
|
+
io << "Server: xxx\n"
|
53
|
+
io << "\n\n"
|
54
|
+
io.rewind
|
55
|
+
io
|
56
|
+
end
|
57
|
+
|
58
|
+
Formatador.display_line('none_match')
|
59
|
+
Formatador.indent do
|
60
|
+
Tach.meter(10_000) do
|
61
|
+
tach('compare on read') do
|
62
|
+
socket, headers = none_match_socket, {}
|
63
|
+
until ((data = socket.readline).chop!).empty?
|
64
|
+
key, value = data.split(': ')
|
65
|
+
headers[key] = value
|
66
|
+
(key.casecmp('Transfer-Encoding') == 0) && (value.casecmp('chunked') == 0)
|
67
|
+
(key.casecmp('Connection') == 0) && (value.casecmp('close') == 0)
|
68
|
+
(key.casecmp('Content-Length') == 0)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
tach('original') do
|
73
|
+
socket, headers = none_match_socket, {}
|
74
|
+
until ((data = socket.readline).chop!).empty?
|
75
|
+
key, value = data.split(': ')
|
76
|
+
headers[key] = value
|
77
|
+
end
|
78
|
+
headers.has_key?('Transfer-Encoding') && headers['Transfer-Encoding'].casecmp('chunked') == 0
|
79
|
+
headers.has_key?('Connection') && headers['Connection'].casecmp('close') == 0
|
80
|
+
headers.has_key?('Content-Length')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/excon.gemspec
CHANGED
@@ -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.5.
|
17
|
-
s.date = '2011-02-
|
16
|
+
s.version = '0.5.3'
|
17
|
+
s.date = '2011-02-17'
|
18
18
|
s.rubyforge_project = 'excon'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -73,6 +73,7 @@ Gem::Specification.new do |s|
|
|
73
73
|
benchmarks/downcase-eq-eq_vs_casecmp.rb
|
74
74
|
benchmarks/excon_vs.rb
|
75
75
|
benchmarks/has_key-vs-hash[key].rb
|
76
|
+
benchmarks/headers_case_sensitivity.rb
|
76
77
|
benchmarks/headers_split_vs_match.rb
|
77
78
|
benchmarks/implicit_block-vs-explicit_block.rb
|
78
79
|
benchmarks/merging.rb
|
data/lib/excon.rb
CHANGED
data/lib/excon/connection.rb
CHANGED
@@ -137,7 +137,7 @@ module Excon
|
|
137
137
|
end
|
138
138
|
|
139
139
|
rescue => request_error
|
140
|
-
if params
|
140
|
+
if params[:idempotent] &&
|
141
141
|
(request_error.is_a?(Excon::Errors::SocketError) ||
|
142
142
|
(request_error.is_a?(Excon::Errors::HTTPStatusError) && response.status != 404))
|
143
143
|
retries_remaining ||= 4
|
data/lib/excon/response.rb
CHANGED
@@ -12,14 +12,15 @@ module Excon
|
|
12
12
|
response = new(:status => socket.readline[9, 11].to_i)
|
13
13
|
block_given = block_given?
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
until ((data = socket.readline).chop!).empty?
|
16
|
+
key, value = data.split(': ')
|
17
|
+
response.headers[key] = value
|
18
|
+
if key.casecmp('Content-Length') == 0
|
19
|
+
@content_length = value.to_i
|
20
|
+
elsif (key.casecmp('Transfer-Encoding') == 0) && (value.casecmp('chunked') == 0)
|
21
|
+
@transfer_encoding_chunked = true
|
22
|
+
elsif (key.casecmp('Connection') == 0) && (value.casecmp('close') == 0)
|
23
|
+
@connection_close = true
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -31,30 +32,30 @@ module Excon
|
|
31
32
|
end
|
32
33
|
|
33
34
|
if block_given
|
34
|
-
if
|
35
|
+
if @transfer_encoding_chunked
|
35
36
|
while (chunk_size = socket.readline.chop!.to_i(16)) > 0
|
36
37
|
yield socket.read(chunk_size + 2).chop! # 2 == "/r/n".length
|
37
38
|
end
|
38
39
|
socket.read(2) # 2 == "/r/n".length
|
39
|
-
elsif
|
40
|
+
elsif @connection_close
|
40
41
|
yield socket.read
|
41
|
-
|
42
|
-
remaining =
|
42
|
+
else
|
43
|
+
remaining = @content_length
|
43
44
|
while remaining > 0
|
44
45
|
yield socket.read([CHUNK_SIZE, remaining].min)
|
45
46
|
remaining -= CHUNK_SIZE
|
46
47
|
end
|
47
48
|
end
|
48
49
|
else
|
49
|
-
if
|
50
|
+
if @transfer_encoding_chunked
|
50
51
|
while (chunk_size = socket.readline.chop!.to_i(16)) > 0
|
51
52
|
response.body << socket.read(chunk_size + 2).chop! # 2 == "/r/n".length
|
52
53
|
end
|
53
54
|
socket.read(2) # 2 == "/r/n".length
|
54
|
-
elsif
|
55
|
+
elsif @connection_close
|
55
56
|
response.body << socket.read
|
56
|
-
|
57
|
-
remaining =
|
57
|
+
else
|
58
|
+
remaining = @content_length
|
58
59
|
while remaining > 0
|
59
60
|
response.body << socket.read([CHUNK_SIZE, remaining].min)
|
60
61
|
remaining -= CHUNK_SIZE
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 3
|
10
|
+
version: 0.5.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- geemus (Wesley Beary)
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-17 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- benchmarks/downcase-eq-eq_vs_casecmp.rb
|
83
83
|
- benchmarks/excon_vs.rb
|
84
84
|
- benchmarks/has_key-vs-hash[key].rb
|
85
|
+
- benchmarks/headers_case_sensitivity.rb
|
85
86
|
- benchmarks/headers_split_vs_match.rb
|
86
87
|
- benchmarks/implicit_block-vs-explicit_block.rb
|
87
88
|
- benchmarks/merging.rb
|
@@ -128,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
129
|
requirements: []
|
129
130
|
|
130
131
|
rubyforge_project: excon
|
131
|
-
rubygems_version: 1.
|
132
|
+
rubygems_version: 1.4.1
|
132
133
|
signing_key:
|
133
134
|
specification_version: 2
|
134
135
|
summary: speed, persistence, http(s)
|