rack-accepts 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rack-accepts.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,31 @@
1
+ ## Summary
2
+
3
+ Rack middleware to reject crappy http accept headers
4
+ Returns '406 Not Acceptable' status when unsupported type is requested.
5
+
6
+ ## Rails Usage
7
+
8
+ config.middleware.use Rack::Accepts
9
+
10
+ ## License
11
+
12
+ Copyright (c) 2010 Andrew Nesbitt
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining
15
+ a copy of this software and associated documentation files (the
16
+ "Software"), to deal in the Software without restriction, including
17
+ without limitation the rights to use, copy, modify, merge, publish,
18
+ distribute, sublicense, and/or sell copies of the Software, and to
19
+ permit persons to whom the Software is furnished to do so, subject to
20
+ the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be
23
+ included in all copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ module Rack
2
+ class Accepts
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def call(env)
8
+ if some_bad_accepts_headers?
9
+ Rack::Response.new([], 406).finish
10
+ else
11
+ @app.call(env)
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def some_bad_accepts_headers
18
+ headers["Accepts"].include? "***"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ class Accepts
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rack/accepts/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rack-accepts"
7
+ s.version = Rack::Accepts::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Andrew Nesbitt"]
10
+ s.email = ["andrewnez@gmail.com"]
11
+ s.homepage = "https://github.com/andrew/rack-accepts"
12
+ s.summary = %q{Rack middleware to reject crappy http accept headers}
13
+ s.description = %q{Rack middleware to reject crappy http accept headers, Returns '406 Not Acceptable' status when unsupported type is requested.}
14
+
15
+ s.rubyforge_project = "rack-accepts"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-accepts
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Andrew Nesbitt
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-31 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Rack middleware to reject crappy http accept headers, Returns '406 Not Acceptable' status when unsupported type is requested.
23
+ email:
24
+ - andrewnez@gmail.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - README
35
+ - Rakefile
36
+ - lib/rack/accepts/accepts.rb
37
+ - lib/rack/accepts/version.rb
38
+ - rack-accepts.gemspec
39
+ has_rdoc: true
40
+ homepage: https://github.com/andrew/rack-accepts
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project: rack-accepts
69
+ rubygems_version: 1.3.7
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Rack middleware to reject crappy http accept headers
73
+ test_files: []
74
+