mongrel_raw_output 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +1 -0
- data/LICENSE +20 -0
- data/README +22 -0
- data/Rakefile +37 -0
- data/lib/mongrel_raw_output/init.rb +22 -0
- data/tools/rakehelp.rb +105 -0
- metadata +68 -0
data/COPYING
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
No copying restrictions/license given.
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2004-2006 Chris Anderson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
== Mongrel_raw_output GemPlugin
|
2
|
+
|
3
|
+
This GemPlugin allows you to specify a special header, 'X-Raw-Output', to make Mongrel output the body of a response as the entire response. This allows you to have full manual control over the http headers and body from any application (Rails, Camping, etc). I've found this useful when mocking the full http response of a foreign server when developing and testing bots and scrapers.
|
4
|
+
|
5
|
+
In Rails the best way to use raw_output is with a file called mongrel_raw_output.conf in your config directory. Its contents should liik like this:
|
6
|
+
|
7
|
+
uri "/",
|
8
|
+
:handler => plugin("/handlers/rawoutput"),
|
9
|
+
:in_front => false
|
10
|
+
|
11
|
+
Then start your Mongrel like this:
|
12
|
+
|
13
|
+
mongrel_rails start -S config/mongrel_raw_output.conf
|
14
|
+
|
15
|
+
In Rails, you can add this method to application.rb
|
16
|
+
|
17
|
+
# send the raw text directly to the client
|
18
|
+
def render_raw raw
|
19
|
+
render :text => raw
|
20
|
+
headers['X-Raw-Output'] = true
|
21
|
+
end
|
22
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'rake/rdoctask'
|
6
|
+
require 'tools/rakehelp'
|
7
|
+
require 'fileutils'
|
8
|
+
include FileUtils
|
9
|
+
|
10
|
+
setup_tests
|
11
|
+
setup_clean ["pkg", "lib/*.bundle", "*.gem", ".config"]
|
12
|
+
|
13
|
+
setup_rdoc ['README', 'LICENSE', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc']
|
14
|
+
|
15
|
+
desc "Does a full compile, test run"
|
16
|
+
task :default => [:test, :package]
|
17
|
+
|
18
|
+
version="0.2.2"
|
19
|
+
name="mongrel_raw_output"
|
20
|
+
|
21
|
+
setup_gem(name, version) do |spec|
|
22
|
+
spec.summary = "The mongrel_raw_output GemPlugin for bypassing Mongrel's headers"
|
23
|
+
spec.description = spec.summary
|
24
|
+
spec.author="Chris Anderson"
|
25
|
+
spec.add_dependency('mongrel', '>= 0.3.13.3')
|
26
|
+
spec.add_dependency('gem_plugin', '>= 0.2.1')
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
task :install => [:test, :package] do
|
31
|
+
sh %{gem install pkg/#{name}-#{version}.gem}
|
32
|
+
end
|
33
|
+
|
34
|
+
task :uninstall => [:clean] do
|
35
|
+
sh %{gem uninstall #{name}}
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'mongrel'
|
2
|
+
require 'gem_plugin'
|
3
|
+
|
4
|
+
class RawOutput < GemPlugin::Plugin "/handlers"
|
5
|
+
include Mongrel::HttpHandlerPlugin
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
@request_notify = false
|
9
|
+
@header_only = false
|
10
|
+
end
|
11
|
+
|
12
|
+
def process(request, response)
|
13
|
+
response.header.out.rewind
|
14
|
+
headers = response.header.out.read
|
15
|
+
return unless headers.match(/X-Raw-Output/)
|
16
|
+
response.instance_variable_set(:@status_sent, true)
|
17
|
+
response.instance_variable_set(:@header_sent, true)
|
18
|
+
response.start(200, true) do |head, body|
|
19
|
+
body.write("")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/tools/rakehelp.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
|
2
|
+
def make(makedir)
|
3
|
+
Dir.chdir(makedir) do
|
4
|
+
sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
def extconf(dir)
|
10
|
+
Dir.chdir(dir) do ruby "extconf.rb" end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def setup_tests
|
15
|
+
Rake::TestTask.new do |t|
|
16
|
+
t.libs << "test"
|
17
|
+
t.test_files = FileList['test/test*.rb']
|
18
|
+
t.verbose = true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def setup_clean otherfiles
|
24
|
+
files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
|
25
|
+
CLEAN.include(files)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def setup_rdoc files
|
30
|
+
Rake::RDocTask.new do |rdoc|
|
31
|
+
rdoc.rdoc_dir = 'doc/rdoc'
|
32
|
+
rdoc.options << '--line-numbers'
|
33
|
+
rdoc.rdoc_files.add(files)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def setup_extension(dir, extension)
|
39
|
+
ext = "ext/#{dir}"
|
40
|
+
ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
|
41
|
+
ext_files = FileList[
|
42
|
+
"#{ext}/*.c",
|
43
|
+
"#{ext}/*.h",
|
44
|
+
"#{ext}/extconf.rb",
|
45
|
+
"#{ext}/Makefile",
|
46
|
+
"lib"
|
47
|
+
]
|
48
|
+
|
49
|
+
task "lib" do
|
50
|
+
directory "lib"
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Builds just the #{extension} extension"
|
54
|
+
task extension.to_sym => ["#{ext}/Makefile", ext_so ]
|
55
|
+
|
56
|
+
file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
|
57
|
+
extconf "#{ext}"
|
58
|
+
end
|
59
|
+
|
60
|
+
file ext_so => ext_files do
|
61
|
+
make "#{ext}"
|
62
|
+
cp ext_so, "lib"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def base_gem_spec(pkg_name, pkg_version)
|
68
|
+
pkg_version = pkg_version
|
69
|
+
pkg_name = pkg_name
|
70
|
+
pkg_file_name = "#{pkg_name}-#{pkg_version}"
|
71
|
+
Gem::Specification.new do |s|
|
72
|
+
s.name = pkg_name
|
73
|
+
s.version = pkg_version
|
74
|
+
s.platform = Gem::Platform::RUBY
|
75
|
+
s.has_rdoc = true
|
76
|
+
s.extra_rdoc_files = [ "README" ]
|
77
|
+
|
78
|
+
s.files = %w(COPYING LICENSE README Rakefile) +
|
79
|
+
Dir.glob("{bin,doc/rdoc,test,lib}/**/*") +
|
80
|
+
Dir.glob("ext/**/*.{h,c,rb}") +
|
81
|
+
Dir.glob("examples/**/*.rb") +
|
82
|
+
Dir.glob("tools/*.rb")
|
83
|
+
|
84
|
+
s.require_path = "lib"
|
85
|
+
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
86
|
+
s.bindir = "bin"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def setup_gem(pkg_name, pkg_version)
|
91
|
+
spec = base_gem_spec(pkg_name, pkg_version)
|
92
|
+
yield spec if block_given?
|
93
|
+
|
94
|
+
Rake::GemPackageTask.new(spec) do |p|
|
95
|
+
p.gem_spec = spec
|
96
|
+
p.need_tar = true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def setup_win32_gem(pkg_name, pkg_version)
|
101
|
+
spec = base_gem_spec(pkg_name, pkg_version)
|
102
|
+
yield spec if block_given?
|
103
|
+
|
104
|
+
Gem::Builder.new(spec).build
|
105
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: mongrel_raw_output
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.2.2
|
7
|
+
date: 2006-11-16 00:00:00 -08:00
|
8
|
+
summary: The mongrel_raw_output GemPlugin for bypassing Mongrel's headers
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email:
|
12
|
+
homepage:
|
13
|
+
rubyforge_project:
|
14
|
+
description: The mongrel_raw_output GemPlugin for bypassing Mongrel's headers
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
authors:
|
29
|
+
- Chris Anderson
|
30
|
+
files:
|
31
|
+
- COPYING
|
32
|
+
- LICENSE
|
33
|
+
- README
|
34
|
+
- Rakefile
|
35
|
+
- lib/mongrel_raw_output
|
36
|
+
- lib/mongrel_raw_output/init.rb
|
37
|
+
- tools/rakehelp.rb
|
38
|
+
test_files: []
|
39
|
+
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- README
|
44
|
+
executables: []
|
45
|
+
|
46
|
+
extensions: []
|
47
|
+
|
48
|
+
requirements: []
|
49
|
+
|
50
|
+
dependencies:
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: mongrel
|
53
|
+
version_requirement:
|
54
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 0.3.13.3
|
59
|
+
version:
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: gem_plugin
|
62
|
+
version_requirement:
|
63
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.2.1
|
68
|
+
version:
|