degzipper 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 133d03636180886243ef7da781c8bbf417f69ed4
4
+ data.tar.gz: e341c4a0b1845d5637ac637e478818e6a6dcc85e
5
+ SHA512:
6
+ metadata.gz: 22a24190a654f2b91eecafc38da5bcdb60328480710351738932066b0defff2b2a1f5b2189e91e7fd94cb7bc84b2e75e942ad4b510cf98e6d0207a6aed8771ab
7
+ data.tar.gz: fccff6dba9d58d991192e78437cb9c1438b0c9dac67b776ff0e68c87e7ee5089e0778dcb0fb9b5d2a1205234f0636e4c135be3b4c3d77b98652ec8182fa6a49a
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Andrew Hammond
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Degzipper
2
+ Rack middleware to inflate incoming Gzip data from HTTP requests.
3
+
4
+ ## Getting Started
5
+ Degzipper is a Rack Middleware. That means that you can use
6
+ it the same way that you use any other Rack middleware. For example, to
7
+ use in a Sinatra application I might do this:
8
+
9
+ ```ruby
10
+ require 'sinatra'
11
+ require 'degzipper'
12
+
13
+ class MyApplication < Sinatra::Base
14
+ use Rack::Session::Cookie
15
+ use Degzipper::Middleware
16
+ end
17
+ ```
18
+
19
+ For a Rails application this is handled for you automatically, just add the gem to your Gemfile.
20
+
21
+ ## Installation
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ gem 'degzipper'
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install degzipper
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
42
+
43
+ ## Credits
44
+ Credit to [relistan](https://github.com/relistan) for the [original gist](https://gist.github.com/relistan/2109707)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/degzipper.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'degzipper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "degzipper"
8
+ spec.version = Degzipper::VERSION
9
+ spec.authors = ["Andrew Hammond", "Bob Breznak"]
10
+ spec.email = ["andrew@evertrue.com"]
11
+ spec.description = %q{Rack middleware to inflate incoming Gzip data from HTTP requests.}
12
+ spec.summary = %q{Rack middleware to inflate incoming Gzip data from HTTP requests.}
13
+ spec.homepage = "http://github.com/andrhamm/degzipper"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,35 @@
1
+ module Degzipper
2
+ class Middleware
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def method_handled?(env)
8
+ !!(env['REQUEST_METHOD'] =~ /(POST|PUT)/)
9
+ end
10
+
11
+ def encoding_handled?(env)
12
+ ['gzip', 'deflate'].include? env['HTTP_CONTENT_ENCODING']
13
+ end
14
+
15
+ def call(env)
16
+ if method_handled?(env) && encoding_handled?(env)
17
+ extracted = decode(env['rack.input'], env['HTTP_CONTENT_ENCODING'])
18
+
19
+ env.delete('HTTP_CONTENT_ENCODING')
20
+ env['CONTENT_LENGTH'] = extracted.length
21
+ env['rack.input'] = StringIO.new(extracted)
22
+ end
23
+
24
+ status, headers, response = @app.call(env)
25
+ return [status, headers, response]
26
+ end
27
+
28
+ def decode(input, content_encoding)
29
+ case content_encoding
30
+ when 'gzip' then Zlib::GzipReader.new(input).read
31
+ when 'deflate' then Zlib::Inflate.inflate(input.read)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ module Degzipper
2
+ class Rails < Rails::Railtie
3
+ initializer "degzipper.configure_rails_initialization" do |app|
4
+ app.middleware.insert_before ActionDispatch::ParamsParser, "Degzipper::Middleware"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Degzipper
2
+ VERSION = "0.0.1"
3
+ end
data/lib/degzipper.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'degzipper/version'
2
+ require 'degzipper/middleware'
3
+ require 'degzipper/rails' if defined?(Rails)
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: degzipper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Hammond
8
+ - Bob Breznak
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: Rack middleware to inflate incoming Gzip data from HTTP requests.
43
+ email:
44
+ - andrew@evertrue.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - degzipper.gemspec
55
+ - lib/degzipper.rb
56
+ - lib/degzipper/middleware.rb
57
+ - lib/degzipper/rails.rb
58
+ - lib/degzipper/version.rb
59
+ homepage: http://github.com/andrhamm/degzipper
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.0
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Rack middleware to inflate incoming Gzip data from HTTP requests.
83
+ test_files: []