foto 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,6 +43,10 @@ module Foto
43
43
  consumer.api_key || Foto::Config.api_key
44
44
  end
45
45
 
46
+ def use_ssl?
47
+ protocol === 'https'
48
+ end
49
+
46
50
  def add_headers(http_request)
47
51
  http_request.add_field('User-Agent', 'Foto')
48
52
  http_request.add_field('Content-Length', content_length)
@@ -53,7 +57,10 @@ module Foto
53
57
  def send_http_request
54
58
  base_uri = URI(Foto::Config.base_uri)
55
59
  http = Net::HTTP.new(base_uri.host, base_uri.port)
56
- http.use_ssl = (protocol === 'https')
60
+ if use_ssl?
61
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
62
+ http.use_ssl = true
63
+ end
57
64
  http.start do |http|
58
65
  Response.new(http.request(http_request))
59
66
  end
@@ -3,14 +3,18 @@ module Foto
3
3
  class Response
4
4
  attr_reader :body, :code
5
5
 
6
+ class InvalidResponse < StandardError; end
7
+
6
8
  def initialize(http_response)
7
9
  @body = http_response.body
8
10
  @code = http_response.code
9
11
  end
10
12
 
11
13
  def message
12
- doc = Nokogiri::HTML(@body)
14
+ doc = Nokogiri::HTML(body)
13
15
  doc.xpath('/html/body/p').first.content
16
+ rescue Exception => e
17
+ raise InvalidResponse, "The response from FOTO could not be parsed.\nHTTP #{code} : #{body}"
14
18
  end
15
19
 
16
20
  def successful?
@@ -1,3 +1,3 @@
1
1
  module Foto
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foto
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter Tran
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-21 00:00:00 Z
18
+ date: 2012-12-26 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: yajl-ruby