kronk 1.7.4 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.rdoc CHANGED
@@ -1,4 +1,10 @@
1
- === 1.7.3 / 2011-10-26
1
+ === 1.7.5 / 2011-10-27
2
+
3
+ * Bugfixes:
4
+
5
+ * Reenabled data parsing for files.
6
+
7
+ === 1.7.4 / 2011-10-26
2
8
 
3
9
  * Bugfixes:
4
10
 
data/lib/kronk.rb CHANGED
@@ -14,7 +14,7 @@ require 'yaml'
14
14
  class Kronk
15
15
 
16
16
  # This gem's version.
17
- VERSION = '1.7.4'
17
+ VERSION = '1.7.5'
18
18
 
19
19
  require 'kronk/constants'
20
20
  require 'kronk/queue_runner'
@@ -61,29 +61,27 @@ class Kronk
61
61
  @headers = @_res.to_hash.dup
62
62
  @headers.keys.each{|h| @headers[h] = @headers[h].join(", ")}
63
63
 
64
- @encoding = "utf-8" unless @_res["Content-Type"]
65
- c_type = [*@headers["content-type"]].find{|ct| ct =~ ENCODING_MATCHER}
64
+ @encoding = "utf-8" unless @headers["content-type"]
65
+ c_type = @headers["content-type"] =~ ENCODING_MATCHER
66
66
  @encoding = $2 if c_type
67
67
  @encoding ||= "ASCII-8BIT"
68
68
  @encoding = Encoding.find(@encoding) if defined?(Encoding)
69
69
 
70
70
  raw_req, raw_resp, bytes = read_raw_from debug_io
71
- @raw = try_force_encoding raw_resp
71
+ @raw = try_force_encoding raw_resp
72
72
 
73
- @request = request ||
74
- raw_req = try_force_encoding(raw_req) &&
75
- Request.parse(raw_req)
73
+ @request = request || raw_req && Request.parse(try_force_encoding raw_req)
76
74
 
77
75
  @time = 0
78
76
 
79
77
  @body = try_force_encoding(@_res.body) if @_res.body
80
78
  @body ||= @raw.split("\r\n\r\n",2)[1]
81
79
 
82
- @bytes = (@_res['Content-Length'] || @body.bytes.count).to_i
80
+ @bytes = (@headers["content-length"] || @body.bytes.count).to_i
83
81
 
84
82
  @code = @_res.code
85
83
 
86
- @parser = Kronk.parser_for @_res['Content-Type']
84
+ @parser = Kronk.parser_for @headers["content-type"]
87
85
 
88
86
  @uri = @request.uri if @request && @request.uri
89
87
  @uri = URI.parse io.path if File === io
@@ -143,7 +141,7 @@ class Kronk
143
141
  # Ruby inspect.
144
142
 
145
143
  def inspect
146
- "#<#{self.class}:#{self.code} #{self['Content-Type']} #{total_bytes}bytes>"
144
+ "#<#{self.class}:#{@code} #{self['Content-Type']} #{total_bytes}bytes>"
147
145
  end
148
146
 
149
147
 
@@ -429,7 +427,8 @@ class Kronk
429
427
 
430
428
  rescue Net::HTTPBadResponse
431
429
  ext = "text/html"
432
- ext = File.extname(resp_io.path) if WinFileIO === resp_io
430
+ ext = File.extname(resp_io.path)[1..-1] if
431
+ WinFileIO === resp_io || File === resp_io
433
432
 
434
433
  resp_io.rewind
435
434
  resp = HeadlessResponse.new resp_io.read, ext
@@ -494,7 +493,6 @@ class Kronk
494
493
  end
495
494
 
496
495
 
497
-
498
496
  ##
499
497
  # Mock response object without a header for body-only http responses.
500
498
 
@@ -510,7 +508,7 @@ class Kronk
510
508
  encoding = body.respond_to?(:encoding) ? body.encoding : "UTF-8"
511
509
 
512
510
  @header = {
513
- 'Content-Type' => ["text/#{file_ext}; charset=#{encoding}"]
511
+ 'Content-Type' => "text/#{file_ext}; charset=#{encoding}"
514
512
  }
515
513
  end
516
514
 
@@ -531,7 +529,12 @@ class Kronk
531
529
  # Interface method only. Returns empty hash.
532
530
 
533
531
  def to_hash
534
- @header
532
+ head_out = @header.dup
533
+ head_out.keys.each do |key|
534
+ head_out[key.downcase] = [head_out.delete(key)]
535
+ end
536
+
537
+ head_out
535
538
  end
536
539
  end
537
540
  end
@@ -66,7 +66,7 @@ class TestResponse < Test::Unit::TestCase
66
66
 
67
67
  assert_equal "just this one line!", resp.body
68
68
  enc = "".encoding rescue "UTF-8"
69
- assert_equal ["text/html; charset=#{enc}"], resp['Content-Type']
69
+ assert_equal "text/html; charset=#{enc}", resp['Content-Type']
70
70
  end
71
71
 
72
72
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kronk
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.7.4
5
+ version: 1.7.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeremie Castagna
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-10-26 00:00:00 Z
13
+ date: 2011-10-27 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json