Skip to content

Commit

Permalink
v0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
benbjohnson committed Jan 28, 2011
1 parent 6f966e9 commit 8874f3a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -1,2 +1,5 @@
v0.1.1
* Fix bug when accessing non-limited hosts.

v0.1.0
* Initial release.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
slowweb (0.1.0)
slowweb (0.1.1)

GEM
remote: http://rubygems.org/
Expand Down
15 changes: 9 additions & 6 deletions lib/slow_web/ext/net_http.rb
Expand Up @@ -7,13 +7,16 @@ def request_with_slowweb(request, body = nil, &block)
host = self.address
limit = SlowWeb.get_limit(host)

# Wait until the request limit is no longer exceeded
while limit.exceeded?
sleep 1
end
# Manage this request if it has been limited
if !limit.nil?
# Wait until the request limit is no longer exceeded
while limit.exceeded?
sleep 1
end

# Add request to limiter
limit.add_request(request)
# Add request to limiter
limit.add_request(request)
end

# Continue with the original request
request_without_slowweb(request, body, &block)
Expand Down
2 changes: 1 addition & 1 deletion lib/slow_web/version.rb
@@ -1,3 +1,3 @@
class SlowWeb
VERSION = '0.1.0'
VERSION = '0.1.1'
end
9 changes: 9 additions & 0 deletions spec/net_http_spec.rb
Expand Up @@ -44,4 +44,13 @@
open('http://github.com')
(Time.now-t).should > 1
end

it 'should ignore unlimited hosts' do
FakeWeb.register_uri(:get, 'http://google.com', :body => 'bar')
SlowWeb.limit('github.com', 3, 60)
open('http://google.com')
open('http://google.com')
open('http://google.com')
open('http://google.com')
end
end

0 comments on commit 8874f3a

Please sign in to comment.