jsl-http_headers 0.0.2 → 0.0.2.1

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.
@@ -1,11 +1,11 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "http_headers"
3
- s.version = "0.0.2"
4
- s.date = "2009-05-22"
3
+ s.version = "0.0.2.1"
4
+ s.date = "2009-05-25"
5
5
  s.summary = "Library for parsing the Curl header_str into attributes"
6
6
  s.email = "justin@phq.org"
7
7
  s.homepage = "http://github.com/jsl/hashback"
8
- s.description = "Creates an object from the attributes in a header_str from Curl"
8
+ s.description = "Parses a HTTP header string into individual header fields"
9
9
  s.has_rdoc = true
10
10
  s.authors = ["Justin Leitgeb"]
11
11
  s.files = [
@@ -36,6 +36,9 @@ class HttpHeaders
36
36
  # Returns the key from this tag, which should be a string with key separated
37
37
  # from val by ':'
38
38
  def value_from(tag)
39
- tag.split(/:\W+/)[1]
39
+ val = tag.split(/:\s+/)[1]
40
+
41
+ # Value may be surrounded by quotes in some cases. Remove these extra quotes here.
42
+ val =~ /^\"(.*)\"$/ ? $1 : val
40
43
  end
41
44
  end
@@ -4,6 +4,7 @@ describe HttpHeaders do
4
4
  before do
5
5
  @h = HttpHeaders.new(File.read(File.join(File.dirname(__FILE__), %w[fixtures headers.txt])))
6
6
  @h2 = HttpHeaders.new(File.read(File.join(File.dirname(__FILE__), %w[fixtures headers2.txt])))
7
+ @h3 = HttpHeaders.new(File.read(File.join(File.dirname(__FILE__), %w[fixtures headers3.txt])))
7
8
  end
8
9
 
9
10
  it "should have text/html as the content_type" do
@@ -22,6 +23,12 @@ describe HttpHeaders do
22
23
  @h2.etag.should == 'pnDSjJtGvlc2WrX6VND/w0qxEc8'
23
24
  end
24
25
 
26
+ # @h3 tests stripping an etag from a value section of a header where the value is wrapped in
27
+ # quotes as given by the HTTP server.
28
+ it "should have an etag of 1edec-3e3073913b100 for headers3" do
29
+ @h3.etag.should == '1edec-3e3073913b100'
30
+ end
31
+
25
32
  it "should have Fri, 22 May 2009 18:18:08 GMT for date" do
26
33
  @h2.date.should == 'Fri, 22 May 2009 18:18:08 GMT'
27
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsl-http_headers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Leitgeb
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-22 00:00:00 -07:00
12
+ date: 2009-05-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: Creates an object from the attributes in a header_str from Curl
16
+ description: Parses a HTTP header string into individual header fields
17
17
  email: justin@phq.org
18
18
  executables: []
19
19