iconoclasm 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -46,7 +46,7 @@ module Iconoclasm
46
46
  :url => naive_url,
47
47
  :content_length => headers.content_length,
48
48
  :content_type => headers.content_type,
49
- :data => response.body_str
49
+ :data => response.body
50
50
  })
51
51
  end
52
52
  end
@@ -1,11 +1,14 @@
1
1
  module Iconoclasm
2
2
  class Headers
3
-
3
+ REGEXP = /^\s*HTTP\/(\d\.\d)\s*(\d{3})\s*(.*)\s*$/i
4
+
4
5
  attr_reader :version, :code, :message
5
6
 
6
- def initialize(header_string)
7
- parse_http_response(header_string.lines.first.chomp)
8
- @header_hash = parse_header_string(header_string)
7
+ def initialize(string)
8
+ header_string = string.dup
9
+ http_response = header_string.slice!(REGEXP)
10
+ @version, @code, @message = parse_http_response(http_response.strip)
11
+ @header_hash = parse_header_string(header_string.strip)
9
12
  end
10
13
 
11
14
  def [](header)
@@ -47,10 +50,8 @@ module Iconoclasm
47
50
  end
48
51
 
49
52
  def parse_http_response(response)
50
- if response.match(/HTTP\/(\d\.\d)\s*(\d{3})\s*(.*)/)
51
- @version = $1
52
- @code = $2.to_i
53
- @message = $3.strip
53
+ if response.match(REGEXP || "")
54
+ [ $1.to_f, $2.to_i, $3.chomp.strip ]
54
55
  else
55
56
  raise Iconoclasm::HTTPError.new(nil, response)
56
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iconoclasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sander Hartlage
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-28 00:00:00 -05:00
12
+ date: 2010-01-07 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15