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.
- data/http_headers.gemspec +3 -3
- data/lib/http_headers.rb +4 -1
- data/spec/http_headers_spec.rb +7 -0
- metadata +3 -3
data/http_headers.gemspec
CHANGED
@@ -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-
|
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 = "
|
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 = [
|
data/lib/http_headers.rb
CHANGED
@@ -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(/:\
|
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
|
data/spec/http_headers_spec.rb
CHANGED
@@ -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-
|
12
|
+
date: 2009-05-25 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: Parses a HTTP header string into individual header fields
|
17
17
|
email: justin@phq.org
|
18
18
|
executables: []
|
19
19
|
|