phantom_client 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -111,9 +111,15 @@ module PhantomJSProxy
111
111
 
112
112
  begin
113
113
  @connection.do_request(element, url, req)
114
- rescue Exception => e
114
+ rescue Net::HTTPBadResponse => e
115
+ raise ProxyErrorLoadingPage, "Proxy could not load Page: #{e}"
116
+ resp = DummyResponse.new()
117
+ resp.code = 500
118
+ resp.body = "Bad Server response"
119
+ return resp
120
+ rescue Timeout::Error, Errno::ECONNREFUSED => e
115
121
  if count == 0
116
- raise NoProxy, "Could not reach any Proxy"
122
+ raise NoProxy, "Could not reach any Proxy: #{e}"
117
123
  resp = DummyResponse.new()
118
124
  resp.code = 500
119
125
  resp.body ="Could not connect to proxy"
@@ -4,7 +4,9 @@ require 'uri'
4
4
  module PhantomJSProxy
5
5
  class PhantomJSClientConnection
6
6
  def do_request(proxy, url, req)
7
- res = Net::HTTP::Proxy(proxy[:addr], proxy[:port]).start(url.host, url.port) {|http|
7
+ conn = Net::HTTP::Proxy(proxy[:addr], proxy[:port]).new(url.host, url.port)
8
+ conn.read_timeout = 180
9
+ res = conn.start() {|http|
8
10
  http.request(req)
9
11
  }
10
12
  return res
@@ -1,5 +1,8 @@
1
1
  module PhantomJSProxy
2
- class NoProxy < Exception
3
-
2
+ class PhantomError < Exception
4
3
  end
5
- end
4
+ class NoProxy < PhantomError
5
+ end
6
+ class ProxyErrorLoadingPage < PhantomError
7
+ end
8
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phantom_client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 5
10
- version: 1.2.5
9
+ - 6
10
+ version: 1.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Sudmann
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-04-23 00:00:00 +02:00
18
+ date: 2013-04-25 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency