Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow options to request to allow changing of read_timeout and possib…

…ly other params. Add ECONNREFUSED as a retriable exception.
  • Loading branch information...
commit a82ef520a6e974fddc42ad702498ba2fdb3a8338 1 parent 0f3266e
@bpardee authored
View
4 .gitignore
@@ -2,3 +2,7 @@
/pkg
/doc
*.swp
+.idea
+Gemfile.lock
+.rvmrc
+*.gem
View
9 Gemfile
@@ -0,0 +1,9 @@
+source "http://rubygems.org"
+
+gem 'gene_pool', '>= 1.0.1'
+
+group :development do
+ gem 'rack'
+ gem 'rake'
+ gem 'rdoc'
+end
View
17 History.md
@@ -0,0 +1,17 @@
+PersistentHttp Changelog
+=====================
+
+1.0.2
+
+ - Allow options to request to allow changing of read_timeout and possibly other params.
+ - Add ECONNREFUSED as a retriable exception.
+
+1.0.1
+
+ - Bug fixes.
+ - Forgot gene_pool dependency
+
+1.0.0
+
+ - Initial release
+
View
9 History.txt
@@ -1,9 +0,0 @@
-=== 1.0.1 / 2010-10-03
-
-* Bug Fixes
- * Forgot gene_pool dependency
-
-=== 1.0.0 / 2010-09-16
-
-* Major Enhancements
- * Based on drbrain/net-http-persistent but uses a connection pool instead of connection/thread
View
2  LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2010 Eric Hodel, Aaron Patterson
+Copyright (c) 2010-2012 Eric Hodel, Aaron Patterson, Brad Pardee
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
44 Rakefile
@@ -1,17 +1,35 @@
+# encoding: UTF-8
require 'rubygems'
-require 'rake'
-
begin
- require 'jeweler'
- Jeweler::Tasks.new do |gemspec|
- gemspec.name = "persistent_http"
- gemspec.summary = "Persistent HTTP connections using a connection pool"
- gemspec.description = "Persistent HTTP connections using a connection pool"
- gemspec.email = "bradpardee@gmail.com"
- gemspec.homepage = "http://github.com/bpardee/persistent_http"
- gemspec.authors = ["Brad Pardee"]
- gemspec.add_dependency 'gene_pool', [">= 1.0.1"]
- end
+ require 'bundler/setup'
rescue LoadError
- puts "Jeweler not available. Install it with: gem install jeweler"
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+
+require 'rake'
+#require 'rake/dsl_definition'
+require 'rdoc/task'
+require 'rake/testtask'
+require 'rake/clean'
+
+desc "Build gem"
+task :gem do |t|
+ system 'gem build persistent_http.gemspec'
+end
+
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = false
+end
+
+task :default => :test
+
+RDoc::Task.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'PersistentHttp'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
end
View
1  VERSION
@@ -1 +0,0 @@
-1.0.1
View
9 lib/persistent_http.rb
@@ -258,7 +258,7 @@ def initialize(options={})
# If there is an error and the request is idempontent according to RFC 2616
# it will be retried automatically.
- def request req = nil, &block
+ def request(req = nil, options = {}, &block)
retried = false
bad_response = false
@@ -273,12 +273,15 @@ def request req = nil, &block
@pool.with_connection do |connection|
begin
+ options.each do |key, value|
+ connection.send("#{key}=", value)
+ end
response = connection.request req, &block
@http_version ||= response.http_version
@count_hash[connection.object_id] += 1
return response
- rescue Timeout::Error => e
+ rescue Timeout::Error => e
due_to = "(due to #{e.message} - #{e.class})"
message = error_message connection
@logger.info "#{name}: Removing connection #{due_to} #{message}" if @logger
@@ -298,7 +301,7 @@ def request req = nil, &block
retry
end
- rescue IOError, EOFError, Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE => e
+ rescue IOError, EOFError, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EPIPE => e
due_to = "(due to #{e.message} - #{e.class})"
message = error_message connection
if retried or not (idempotent? req or @force_retry)
View
60 persistent_http.gemspec
@@ -1,53 +1,11 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
-# -*- encoding: utf-8 -*-
-
Gem::Specification.new do |s|
- s.name = %q{persistent_http}
- s.version = "1.0.1"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Brad Pardee"]
- s.date = %q{2010-10-04}
- s.description = %q{Persistent HTTP connections using a connection pool}
- s.email = %q{bradpardee@gmail.com}
- s.extra_rdoc_files = [
- "LICENSE",
- "README.rdoc"
- ]
- s.files = [
- ".gitignore",
- "History.txt",
- "LICENSE",
- "README.rdoc",
- "Rakefile",
- "VERSION",
- "lib/persistent_http.rb",
- "lib/persistent_http/faster.rb",
- "persistent_http.gemspec",
- "test/persistent_http_test.rb"
- ]
- s.homepage = %q{http://github.com/bpardee/persistent_http}
- s.rdoc_options = ["--charset=UTF-8"]
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.6}
- s.summary = %q{Persistent HTTP connections using a connection pool}
- s.test_files = [
- "test/persistent_http_test.rb"
- ]
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<gene_pool>, [">= 1.0.1"])
- else
- s.add_dependency(%q<gene_pool>, [">= 1.0.1"])
- end
- else
- s.add_dependency(%q<gene_pool>, [">= 1.0.1"])
- end
+ s.name = "persistent_http"
+ s.summary = 'Persistent HTTP connections using a connection pool'
+ s.description = 'Persistent HTTP connections using a connection pool'
+ s.authors = ['Brad Pardee']
+ s.email = ['bradpardee@gmail.com']
+ s.homepage = 'http://github.com/bpardee/persistent_http'
+ s.files = Dir["{examples,lib}/**/*"] + %w(LICENSE Rakefile History.md README.rdoc)
+ s.version = '1.0.2'
+ s.add_dependency 'gene_pool', '>= 1.0.1'
end
-
Please sign in to comment.
Something went wrong with that request. Please try again.