ftw 0.0.33 → 0.0.34

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ftw/agent.rb CHANGED
@@ -302,13 +302,22 @@ class FTW::Agent
302
302
  def execute(request)
303
303
  # TODO(sissel): Make redirection-following optional, but default.
304
304
 
305
- connection, error = connect(request.headers["Host"], request.port,
306
- request.protocol == "https")
307
- if !error.nil?
308
- p :error => error
309
- raise error
305
+ tries = 3
306
+ begin
307
+ connection, error = connect(request.headers["Host"], request.port,
308
+ request.protocol == "https")
309
+ if !error.nil?
310
+ p :error => error
311
+ raise error
312
+ end
313
+ response = request.execute(connection)
314
+ rescue EOFError => e
315
+ tries -= 1
316
+ @logger.warn("Error while sending request, will retry.",
317
+ :tries_left => tries,
318
+ :exception => e)
319
+ retry if tries > 0
310
320
  end
311
- response = request.execute(connection)
312
321
 
313
322
  redirects = 0
314
323
  # Follow redirects
@@ -232,7 +232,9 @@ class FTW::Connection
232
232
  if readable?(timeout)
233
233
  begin
234
234
  # Read at most 'length' data, so read less from the socket
235
- @socket.sysread(@read_size - data.length, @read_buffer)
235
+ # We'll read less than 'length' if the pushback buffer has
236
+ # data in it already.
237
+ @socket.sysread(length - data.length, @read_buffer)
236
238
  data << @read_buffer
237
239
  return data
238
240
  rescue EOFError => e
data/lib/ftw/protocol.rb CHANGED
@@ -134,12 +134,21 @@ module FTW::Protocol
134
134
  end
135
135
  end # def read_body
136
136
 
137
+ # A shorthand for discarding the body of a request or response.
138
+ #
139
+ # This is the same as:
140
+ #
141
+ # foo.read_body { |c| }
142
+ def discard_body
143
+ read_body { |c| }
144
+ end # def discard_body
145
+
137
146
  # Read the length bytes from the body. Yield each chunk read to the block
138
147
  # given. This method is generally only called by http clients, not servers.
139
148
  def read_http_body_length(length, &block)
140
149
  remaining = length
141
150
  while remaining > 0
142
- data = @body.read
151
+ data = @body.read(remaining)
143
152
  @logger.debug("Read bytes", :length => data.size)
144
153
  if data.size > remaining
145
154
  # Read too much data, only wanted part of this. Push the rest back.
@@ -165,6 +174,9 @@ module FTW::Protocol
165
174
  parser.on_message_complete = proc { done = true }
166
175
 
167
176
  while !done # will break on special conditions below
177
+ # TODO(sissel): In JRuby, this read will sometimes hang for ever
178
+ # because there's some wonkiness in IO.select on SSLSockets in JRuby.
179
+ # Maybe we should fix it...
168
180
  data = @body.read
169
181
  offset = parser << data
170
182
  if offset != data.length
data/lib/ftw/version.rb CHANGED
@@ -3,5 +3,5 @@ require "ftw/namespace"
3
3
  # :nodoc:
4
4
  module FTW
5
5
  # The version of this library
6
- VERSION = "0.0.33"
6
+ VERSION = "0.0.34"
7
7
  end
metadata CHANGED
@@ -1,98 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
5
- prerelease:
4
+ version: 0.0.34
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jordan Sissel
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-08 00:00:00.000000000 Z
12
+ date: 2013-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- type: :runtime
15
+ name: cabin
16
16
  version_requirements: !ruby/object:Gem::Requirement
17
- none: false
18
17
  requirements:
19
- - - ! '>'
18
+ - - '>'
20
19
  - !ruby/object:Gem::Version
21
20
  version: '0'
22
- name: cabin
23
- prerelease: false
24
- requirement: !ruby/object:Gem::Requirement
25
21
  none: false
22
+ requirement: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ! '>'
24
+ - - '>'
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
- - !ruby/object:Gem::Dependency
27
+ none: false
28
+ prerelease: false
31
29
  type: :runtime
30
+ - !ruby/object:Gem::Dependency
31
+ name: http_parser.rb
32
32
  version_requirements: !ruby/object:Gem::Requirement
33
- none: false
34
33
  requirements:
35
34
  - - '='
36
35
  - !ruby/object:Gem::Version
37
36
  version: 0.5.3
38
- name: http_parser.rb
39
- prerelease: false
40
- requirement: !ruby/object:Gem::Requirement
41
37
  none: false
38
+ requirement: !ruby/object:Gem::Requirement
42
39
  requirements:
43
40
  - - '='
44
41
  - !ruby/object:Gem::Version
45
42
  version: 0.5.3
46
- - !ruby/object:Gem::Dependency
43
+ none: false
44
+ prerelease: false
47
45
  type: :runtime
46
+ - !ruby/object:Gem::Dependency
47
+ name: addressable
48
48
  version_requirements: !ruby/object:Gem::Requirement
49
- none: false
50
49
  requirements:
51
- - - ! '>='
50
+ - - '>='
52
51
  - !ruby/object:Gem::Version
53
52
  version: '0'
54
- name: addressable
55
- prerelease: false
56
- requirement: !ruby/object:Gem::Requirement
57
53
  none: false
54
+ requirement: !ruby/object:Gem::Requirement
58
55
  requirements:
59
- - - ! '>='
56
+ - - '>='
60
57
  - !ruby/object:Gem::Version
61
58
  version: '0'
62
- - !ruby/object:Gem::Dependency
59
+ none: false
60
+ prerelease: false
63
61
  type: :runtime
62
+ - !ruby/object:Gem::Dependency
63
+ name: backports
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
- none: false
66
65
  requirements:
67
- - - ! '>='
66
+ - - '>='
68
67
  - !ruby/object:Gem::Version
69
68
  version: 2.6.2
70
- name: backports
71
- prerelease: false
72
- requirement: !ruby/object:Gem::Requirement
73
69
  none: false
70
+ requirement: !ruby/object:Gem::Requirement
74
71
  requirements:
75
- - - ! '>='
72
+ - - '>='
76
73
  - !ruby/object:Gem::Version
77
74
  version: 2.6.2
75
+ none: false
76
+ prerelease: false
77
+ type: :runtime
78
78
  - !ruby/object:Gem::Dependency
79
- type: :development
79
+ name: minitest
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
- none: false
82
81
  requirements:
83
- - - ! '>'
82
+ - - '>'
84
83
  - !ruby/object:Gem::Version
85
84
  version: '0'
86
- name: minitest
87
- prerelease: false
88
- requirement: !ruby/object:Gem::Requirement
89
85
  none: false
86
+ requirement: !ruby/object:Gem::Requirement
90
87
  requirements:
91
- - - ! '>'
88
+ - - '>'
92
89
  - !ruby/object:Gem::Version
93
90
  version: '0'
94
- description: For The Web. Trying to build a solid and sane API for client and server
95
- web stuff. Client and Server operations for HTTP, WebSockets, SPDY, etc.
91
+ none: false
92
+ prerelease: false
93
+ type: :development
94
+ description: For The Web. Trying to build a solid and sane API for client and server web stuff. Client and Server operations for HTTP, WebSockets, SPDY, etc.
96
95
  email:
97
96
  - jls@semicomplete.com
98
97
  executables: []
@@ -100,6 +99,7 @@ extensions: []
100
99
  extra_rdoc_files: []
101
100
  files:
102
101
  - lib/ftw.rb
102
+ - lib/rack/handler/ftw.rb
103
103
  - lib/ftw/websocket.rb
104
104
  - lib/ftw/protocol.rb
105
105
  - lib/ftw/webserver.rb
@@ -126,7 +126,6 @@ files:
126
126
  - lib/ftw/dns/dns.rb
127
127
  - lib/ftw/http/headers.rb
128
128
  - lib/ftw/http/message.rb
129
- - lib/rack/handler/ftw.rb
130
129
  - test/docs.rb
131
130
  - test/all.rb
132
131
  - test/testing.rb
@@ -138,28 +137,28 @@ files:
138
137
  homepage: http://github.com/jordansissel/ruby-ftw
139
138
  licenses:
140
139
  - Apache License (2.0)
141
- post_install_message:
140
+ post_install_message:
142
141
  rdoc_options: []
143
142
  require_paths:
144
143
  - lib
145
144
  - lib
146
145
  required_ruby_version: !ruby/object:Gem::Requirement
147
- none: false
148
146
  requirements:
149
- - - ! '>='
147
+ - - '>='
150
148
  - !ruby/object:Gem::Version
151
149
  version: '0'
152
- required_rubygems_version: !ruby/object:Gem::Requirement
153
150
  none: false
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
152
  requirements:
155
- - - ! '>='
153
+ - - '>='
156
154
  - !ruby/object:Gem::Version
157
155
  version: '0'
156
+ none: false
158
157
  requirements: []
159
- rubyforge_project:
160
- rubygems_version: 1.8.25
161
- signing_key:
158
+ rubyforge_project:
159
+ rubygems_version: 1.8.24
160
+ signing_key:
162
161
  specification_version: 3
163
- summary: For The Web. Trying to build a solid and sane API for client and server web
164
- stuff. Client and Server operations for HTTP, WebSockets, SPDY, etc.
162
+ summary: For The Web. Trying to build a solid and sane API for client and server web stuff. Client and Server operations for HTTP, WebSockets, SPDY, etc.
165
163
  test_files: []
164
+ has_rdoc: