Permalink
Browse files

Added timeouts to read and writes, set in Encosion.options

  • Loading branch information...
cannikin committed Nov 30, 2009
1 parent b32db77 commit ba0ffd96d9779e4bbd9b0a4edeeb93c15c45920f
Showing with 19 additions and 7 deletions.
  1. +7 −3 encosion.gemspec
  2. +5 −2 lib/encosion.rb
  3. +4 −2 lib/encosion/base.rb
  4. +3 −0 lib/encosion/video.rb
View
@@ -1,12 +1,15 @@
+# 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{encosion}
- s.version = "0.3.0"
+ s.version = "0.3.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Rob Cameron"]
- s.date = %q{2009-08-04}
+ s.date = %q{2009-11-30}
s.email = %q{cannikinn@gmail.com}
s.extra_rdoc_files = [
"LICENSE",
@@ -35,7 +38,7 @@ Gem::Specification.new do |s|
s.homepage = %q{http://github.com/cannikin/encosion}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.4}
+ s.rubygems_version = %q{1.3.5}
s.summary = %q{Ruby library for working with the Brightcove API}
s.test_files = [
"test/encosion_test.rb",
@@ -58,3 +61,4 @@ Gem::Specification.new do |s|
s.add_dependency(%q<json>, [">= 1.1.7"])
end
end
+
View
@@ -1,6 +1,7 @@
$:.unshift File.dirname(__FILE__) # for use/testing when no gem is installed
# external
+require 'rubygems'
require 'net/http'
require 'net/https'
require 'uri'
@@ -17,7 +18,7 @@
module Encosion
- VERSION = '0.3.0'
+ VERSION = '0.3.1'
LOGGER = Logger.new(STDOUT)
SERVER = 'api.brightcove.com'
@@ -33,7 +34,9 @@ module Encosion
:port => PORT,
:secure => SECURE,
:read_path => READ_PATH,
- :write_path => WRITE_PATH }
+ :write_path => WRITE_PATH,
+ :send_timeout => 120,
+ :receive_timeout => 60 }
attr_accessor :options
# make @options available so it can be set externally when using the library
View
@@ -53,8 +53,9 @@ def all(*args)
# Performs an HTTP GET
- def get(server,port,secure,path,command,options)
+ def get(server,port,secure,path,timeout,command,options)
http = HTTPClient.new
+ http.receive_timeout = timeout
url = secure ? 'https://' : 'http://'
url += "#{server}:#{port}#{path}"
@@ -75,8 +76,9 @@ def get(server,port,secure,path,command,options)
# Performs an HTTP POST
- def post(server,port,secure,path,command,options,instance)
+ def post(server,port,secure,path,timeout,command,options,instance)
http = HTTPClient.new
+ http.send_timeout = timeout
url = secure ? 'https://' : 'http://'
url += "#{server}:#{port}#{path}"
View
@@ -138,6 +138,7 @@ def read(method,options)
Encosion.options[:port],
Encosion.options[:secure],
Encosion.options[:read_path],
+ Encosion.options[:read_timeout],
method,
options)
end
@@ -151,6 +152,7 @@ def write(method,options)
Encosion.options[:port],
Encosion.options[:secure],
Encosion.options[:write_path],
+ Encosion.options[:send_timeout],
method,
options,
self)
@@ -246,6 +248,7 @@ def save(args={})
Encosion.options[:port],
Encosion.options[:secure],
Encosion.options[:write_path],
+ Encosion.options[:send_timeout],
'create_video',
options,
self)

0 comments on commit ba0ffd9

Please sign in to comment.