gateway-http 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzEyNWRmZjE0M2MzNGUyYWZlOTA4OTRkY2I5MGJmOWY2YmJlYjk3NA==
4
+ NGNhYTdlOTEyMDYyM2E0MDg3YWQ5YzVmODljMzJhZmZiYTBkYWFmZg==
5
5
  data.tar.gz: !binary |-
6
- ZDE1MjcxOThjNjBjMDQ3MWY0ZTQ1OGFmNjRjZGMxNTY5NWI3OTYzZQ==
6
+ MGVmM2FhZTRiOGU3MTQwYjE2ZjAxZWFlMTNhN2IyMTNjMzRhZWU4NA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YTBmNGY2ZTYwZDc1ZWIwMzI5YzAyMGRhMzAxOTQ1MmU1YWYxMGI3ZDBmNTEz
10
- YmQ0NGFmMmZkZjMyMjkzMDBiZGY5MGE4YzFhZDIzNmI1NGU4YTdkZjIwZjU1
11
- NTIzMzg2ZGI0NTk2YTRkODZmZDQ0OWI5YmZmZDIwZDI5M2ZhNDY=
9
+ YzkyNWUyODYxNDExZjY2YTdiMzY3NTQ2NmExMmExMDJiMTZjOWM3ZjQzNzlm
10
+ ZDIxY2E0MDBkMjU1OGM5N2VkMDNmN2VjYTIyZjBmN2VlNjQxYzc0YjdlOGY1
11
+ MzIyNDRlZGI5MGUwYzIwOTY4ODUyZjdiNDM4OGM5ODA1ZjA3NzY=
12
12
  data.tar.gz: !binary |-
13
- OWNiNjUyYjMwY2Y1ZjQ2NGUzMmYwNzQwYjlhM2UwMmNmZDM3ZmRiNjA1NDNj
14
- ZGUwMjVhZmQ2OTg4NjNiNDQ3NWViYzRiYTA3N2VmNzg1MmFiZDY4MmJhMDQx
15
- NTNkNTY5ZDg2NjBhMDAzYzVlMDRjNTQ5OGJjNWJkYzVkMzM1Nzg=
13
+ YzcxNjdhM2ZkNjZjNGMxOTcwOTY4NGYyYTU1ZTUyMjVmNzVmYjU3MTA5YWFh
14
+ YjMxYzJiMDYzM2E5NTJhMjZmMjRlZDhhMTYwMmYwNDg0OTkwYzNjMWI1NTI2
15
+ NWY3YWY1OTE3MGIzNjMxZTJjNGMzOTVmYzc4YjEzYTQ3M2MxYzE=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.3.0
data/gateway-http.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gateway-http"
8
- s.version = "0.2.4"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Qian"]
12
- s.date = "2013-05-23"
12
+ s.date = "2013-07-28"
13
13
  s.description = " Gateway wrapper client for Net::HTTP "
14
14
  s.email = "aq1018@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.homepage = "http://github.com/aq1018/gateway-http"
34
34
  s.licenses = ["MIT"]
35
35
  s.require_paths = ["lib"]
36
- s.rubygems_version = "2.0.3"
36
+ s.rubygems_version = "2.0.5"
37
37
  s.summary = "Gateway wrapper client for Net::HTTP"
38
38
 
39
39
  if s.respond_to? :specification_version then
data/lib/gateway/http.rb CHANGED
@@ -36,13 +36,19 @@ module Gateway
36
36
  @host = @address.host
37
37
  @port = @address.port
38
38
  @header = opts[:header] || {}
39
+
40
+ #TCP socket optimizations
41
+ @socket_options = []
42
+ @socket_options << [Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1] if
43
+ Socket.const_defined? :TCP_NODELAY
44
+ @socket_options << opts[:socket_options] if opts[:socket_options]
39
45
  end
40
46
 
41
47
  def pipeline(requests, opts={}, &block)
42
48
  msg = requests.map{|r| absolute_url(r).to_s }.join(',')
43
49
 
44
50
  execute('pipeline', msg, opts) do |conn|
45
- conn.start unless conn.started?
51
+ start conn unless conn.started?
46
52
  conn.pipeline(requests.dup, &block)
47
53
  end
48
54
  end
@@ -56,7 +62,7 @@ module Gateway
56
62
  action = req.method.downcase.to_sym
57
63
 
58
64
  execute(action, absolute_url(req), opts) do |conn|
59
- conn.start unless conn.started?
65
+ start conn unless conn.started?
60
66
  rsp = conn.request(req)
61
67
  validate_response(req, rsp, valid_responses(opts)) if validate_response?(opts)
62
68
  rsp
@@ -153,11 +159,11 @@ module Gateway
153
159
  protected
154
160
 
155
161
  def success_status(resp)
156
- resp.code
162
+ resp.respond_to?(:code) ? resp.code : super
157
163
  end
158
164
 
159
165
  def success_message(resp)
160
- resp.message
166
+ resp.respond_to?(:message) ? resp.message : super
161
167
  end
162
168
 
163
169
  def connect
@@ -165,9 +171,22 @@ module Gateway
165
171
  conn.use_ssl = use_ssl
166
172
  conn.read_timeout = read_timeout if read_timeout
167
173
  conn.open_timeout = open_timeout if open_timeout
174
+
175
+ start conn
176
+
168
177
  conn
169
178
  end
170
179
 
180
+ def start conn
181
+ conn.start
182
+
183
+ socket = conn.instance_variable_get :@socket
184
+
185
+ @socket_options.each do |option|
186
+ socket.io.setsockopt(*option)
187
+ end
188
+ end
189
+
171
190
  def disconnect(conn)
172
191
  conn.finish
173
192
  rescue IOError
@@ -175,6 +194,7 @@ module Gateway
175
194
 
176
195
  def reconnect(conn)
177
196
  disconnect(conn)
197
+ start conn
178
198
  conn
179
199
  end
180
200
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gateway-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Qian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-23 00:00:00.000000000 Z
11
+ date: 2013-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gateway
@@ -148,9 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  requirements: []
150
150
  rubyforge_project:
151
- rubygems_version: 2.0.3
151
+ rubygems_version: 2.0.5
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Gateway wrapper client for Net::HTTP
155
155
  test_files: []
156
- has_rdoc: