web_fetch 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc2d09b5ad2253bdc730796a48ce5c6d08adacf91bee689aeb6dc50602199c63
4
- data.tar.gz: 9ec7709c430d9a9b64f1de87301ee674f85f91412f2f2d108fba5a6179d031c8
3
+ metadata.gz: 6f2284ce2ad4cac05effcd7ae1502f269ceb9d3b1b99f66be1e3ef8cdd6bd786
4
+ data.tar.gz: 04c3a091ced9abff4330b6bfca921d6be78df3b1842191082af8f7bffd2ba7a0
5
5
  SHA512:
6
- metadata.gz: 7120f22d17fda9952b486b894315068504a99124e6a048908a0fc233c309edca4a4edaad5980e03166bf01f59bcaac415fda56b461f467164fc216272fbbfc7e
7
- data.tar.gz: 2f9c1cdee57f1c9ccf219c619b78f4fa8d3fd6dbb058d9e8374fd41c5b7b74c10a99e173d6bda8373e5e181694793f8eab763c378ff6fc15cb25728115c77782
6
+ metadata.gz: 92d7b6dc31b2d981a9679b4896325e77d397689ab54aca28ba4340234855a7c0e0e2ef7cedae655e147dca977a36ce025cf18a02306f680a1167d88f0ecf6690
7
+ data.tar.gz: a5894ebdac3925968cb28538f5891a102515c1c392f9a9b00b39bf839f1fb7bc6cb4ce54f0c3341879292425475ce17a6b36b6ff209472eac737fcfc3e951cbc
data/.gitignore CHANGED
@@ -13,3 +13,6 @@
13
13
  *#
14
14
  #*
15
15
  .#*
16
+
17
+ bin/*.pid
18
+ web_fetch-*.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- web_fetch (0.1.0)
4
+ web_fetch (0.1.1)
5
5
  activesupport (~> 4.0)
6
6
  childprocess (~> 0.5)
7
7
  daemons (~> 1.2)
@@ -10,13 +10,15 @@ module WebFetch
10
10
  end
11
11
 
12
12
  def compress(string)
13
+ return string unless accept_gzip?
14
+
13
15
  ActiveSupport::Gzip.compress(string)
14
16
  end
15
17
 
16
18
  def default_headers(response)
17
19
  response.headers['Content-Type'] = 'application/json; charset=utf-8'
18
20
  response.headers['Cache-Control'] = 'max-age=0, private, must-revalidate'
19
- response.headers['Content-Encoding'] = 'gzip'
21
+ response.headers['Content-Encoding'] = 'gzip' if accept_gzip?
20
22
  response.headers['Vary'] = 'Accept-Encoding'
21
23
  end
22
24
 
@@ -67,5 +69,10 @@ module WebFetch
67
69
  },
68
70
  uid: deferred[:uid] }
69
71
  end
72
+
73
+ def accept_gzip?
74
+ # em-http-request doesn't do us any favours with parsing the HTTP headers
75
+ @http_headers.downcase.include?('accept-encoding: gzip')
76
+ end
70
77
  end
71
78
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebFetch
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_fetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell