http-request 1.2.0 → 1.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/lib/http-request.rb +1 -0
- data/lib/http-request/connection.rb +1 -1
- data/lib/http-request/response.rb +4 -2
- data/lib/http-request/version.rb +1 -1
- metadata +3 -3
data/lib/http-request.rb
CHANGED
@@ -89,7 +89,7 @@ module HttpRequest
|
|
89
89
|
headers['User-Agent'] ||= user_agent
|
90
90
|
headers['Connection'] ||= 'keep-alive' if keep_alive
|
91
91
|
headers['Content-Length'] ||= body.bytesize.to_s if body
|
92
|
-
headers['Accept-Encoding'] ||= 'gzip
|
92
|
+
headers['Accept-Encoding'] ||= 'gzip' # TODO: add deflate support
|
93
93
|
|
94
94
|
# Build request
|
95
95
|
req_klass = instance_eval("Net::HTTP::"+verb.to_s.capitalize)
|
@@ -14,14 +14,16 @@ module HttpRequest
|
|
14
14
|
|
15
15
|
# Auto deflate compressed content
|
16
16
|
content_encoding = @header['content-encoding'].to_s.downcase
|
17
|
-
if !content_encoding.empty? &&
|
17
|
+
if !content_encoding.empty? && content_encoding =~ /gzip/
|
18
18
|
gz = Zlib::GzipReader.new(StringIO.new(@body))
|
19
|
+
@body = gz.read
|
19
20
|
end
|
20
21
|
|
21
22
|
# Use encoding suggested by charset
|
22
23
|
charset = @header['content-type'].to_s.match(/charset=([a-z0-9-]*)/i).to_s
|
23
24
|
if !charset.empty?
|
24
|
-
|
25
|
+
encoding = Encoding.find(charset.split('=')[1]) rescue 'utf-8'
|
26
|
+
@body.force_encoding(encoding)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
data/lib/http-request/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http-request
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -86,7 +86,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
segments:
|
88
88
|
- 0
|
89
|
-
hash:
|
89
|
+
hash: 2860803797911007449
|
90
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
91
|
none: false
|
92
92
|
requirements:
|