jacana 0.0.3 → 0.0.4
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 +4 -4
- data/lib/jacana/server.rb +83 -0
- metadata +2 -8
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/README.md +0 -31
- data/Rakefile +0 -1
- data/jacana.gemspec +0 -19
- data/lib/jacana/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 086d3508df8713cf664d2d8798ba0b479281e2d7
|
4
|
+
data.tar.gz: 466c912673dc868f58a332a5920292c30184aa52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5ea5616e74f07a439707d5d8edfe2934d126e539485ff1ec2f7b6af8bc35530b216d3859d304f550814b252e09df8b921ca5ccd04ab9050d2f01eccd40bc240
|
7
|
+
data.tar.gz: 04d3a05069006b6fa3144fc279ba2c6b25c8d47c43b2ddf40545cf8b449a3f628713a588ae8ea6a1ffede72875decb939d7f6d6ff2761cedc79a82063fbbc33c
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'webrick/config'
|
4
|
+
require 'webrick/httpservlet/abstract'
|
5
|
+
|
6
|
+
module WEBrick
|
7
|
+
module HTTPServlet
|
8
|
+
module Jacana
|
9
|
+
class PHPHandler < AbstractServlet
|
10
|
+
PHPCGI = 'php-cgi'
|
11
|
+
|
12
|
+
def initialize(server, name)
|
13
|
+
super(server, name)
|
14
|
+
@phpcmd = File.join(@server[:Php_Path], PHPCGI)
|
15
|
+
@php_fullpath_script = name
|
16
|
+
end
|
17
|
+
|
18
|
+
def do_GET(req, res)
|
19
|
+
data = nil
|
20
|
+
status = -1
|
21
|
+
|
22
|
+
meta = req.meta_vars
|
23
|
+
meta["SCRIPT_FILENAME"] = @php_fullpath_script
|
24
|
+
meta["PATH"] = @config[:Php_Path]
|
25
|
+
meta["REDIRECT_STATUS"] = "200" # php-cgi/apache specific value
|
26
|
+
if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
27
|
+
meta["SystemRoot"] = ENV["SystemRoot"]
|
28
|
+
end
|
29
|
+
ENV.update(meta)
|
30
|
+
|
31
|
+
cgi_in = IO::popen(@phpcmd, "r+b")
|
32
|
+
begin
|
33
|
+
cgi_in.sync = true
|
34
|
+
|
35
|
+
if req.body and req.body.bytesize > 0
|
36
|
+
cgi_in.write(req.body)
|
37
|
+
end
|
38
|
+
cgi_in.close_write
|
39
|
+
ensure
|
40
|
+
data = cgi_in.read
|
41
|
+
cgi_in.close_read
|
42
|
+
status = $?.exitstatus
|
43
|
+
sleep 0.1 if /mswin|bccwin|mingw/ =~ RUBY_PLATFORM
|
44
|
+
end
|
45
|
+
|
46
|
+
@script_filename = meta['SCRIPT_NAME']
|
47
|
+
if status != 0
|
48
|
+
@logger.error("PHPHandler: #{@script_filename} exit with #{status}")
|
49
|
+
end
|
50
|
+
|
51
|
+
data = "" unless data
|
52
|
+
raw_header, body = data.split(/^[\xd\xa]+/, 2)
|
53
|
+
raise HTTPStatus::InternalServerError,
|
54
|
+
"PHPHandler: Premature end of script headers: #{@script_filename}" if body.nil?
|
55
|
+
|
56
|
+
begin
|
57
|
+
header = HTTPUtils::parse_header(raw_header)
|
58
|
+
if /^(\d+)/ =~ header['status'][0]
|
59
|
+
res.status = $1.to_i
|
60
|
+
header.delete('status')
|
61
|
+
end
|
62
|
+
if header.has_key?('location')
|
63
|
+
# RFC 3875 6.2.3, 6.2.4
|
64
|
+
res.status = 302 unless (300...400) === res.status
|
65
|
+
end
|
66
|
+
if header.has_key?('set-cookie')
|
67
|
+
header['set-cookie'].each { |k|
|
68
|
+
res.cookies << Cookie.parse_set_cookie(k)
|
69
|
+
}
|
70
|
+
header.delete('set-cookie')
|
71
|
+
end
|
72
|
+
header.each { |key, val| res[key] = val.join(", ") }
|
73
|
+
rescue => ex
|
74
|
+
raise HTTPStatus::InternalServerError, ex.message
|
75
|
+
end
|
76
|
+
res.body = body
|
77
|
+
end
|
78
|
+
|
79
|
+
alias do_POST do_GET
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jacana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sedat ÇİFTÇİ
|
@@ -18,15 +18,9 @@ executables:
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- .gitignore
|
22
|
-
- Gemfile
|
23
|
-
- LICENSE.txt
|
24
|
-
- README.md
|
25
|
-
- Rakefile
|
26
21
|
- bin/jacana
|
27
|
-
- jacana.gemspec
|
28
22
|
- lib/jacana.rb
|
29
|
-
- lib/jacana/
|
23
|
+
- lib/jacana/server.rb
|
30
24
|
homepage: ''
|
31
25
|
licenses:
|
32
26
|
- MIT
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Sedat ÇİFTÇİ
|
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
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# Jacana
|
2
|
-
|
3
|
-
TODO: Write a gem description
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'jacana'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install jacana
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
$ jacana
|
22
|
-
|
23
|
-
## Options
|
24
|
-
|
25
|
-
-d /PATH -> Web Directory
|
26
|
-
-p 1453 -> Web Port
|
27
|
-
-s /PATH -> PHP Path
|
28
|
-
|
29
|
-
## Example
|
30
|
-
|
31
|
-
$ jacana -d /var/www -p 8000 -s /usr/local/bin
|
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/jacana.gemspec
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'jacana/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "jacana"
|
8
|
-
spec.version = Jacana::VERSION
|
9
|
-
spec.authors = ["Sedat ÇİFTÇİ"]
|
10
|
-
spec.email = ["iamcodegrab@gmail.com"]
|
11
|
-
spec.description = %q{Jacana WEBRick PHP Handler}
|
12
|
-
spec.summary = %q{Jacana WEBRick PHP Handler}
|
13
|
-
spec.homepage = ""
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables << "jacana"
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
end
|
data/lib/jacana/version.rb
DELETED