hoof 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source "http://rubygems.org"
3
3
  gem 'daemons'
4
4
  gem 'eventmachine'
5
5
  gem 'unicorn'
6
- gem 'http_parser'
6
+ gem 'eventmachine_httpserver'
7
7
  gem 'thor'
8
8
 
9
9
  group :development do
@@ -3,8 +3,8 @@ GEM
3
3
  specs:
4
4
  daemons (1.1.3)
5
5
  eventmachine (0.12.10)
6
+ eventmachine_httpserver (0.2.1)
6
7
  git (1.2.5)
7
- http_parser (0.1.3)
8
8
  jeweler (1.6.0)
9
9
  bundler (~> 1.0.0)
10
10
  git (>= 1.2.5)
@@ -26,7 +26,7 @@ DEPENDENCIES
26
26
  bundler (~> 1.0.0)
27
27
  daemons
28
28
  eventmachine
29
- http_parser
29
+ eventmachine_httpserver
30
30
  jeweler (~> 1.6.0)
31
31
  rcov
32
32
  shoulda
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hoof}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["pyromaniac"]
12
- s.date = %q{2011-05-17}
12
+ s.date = %q{2011-06-08}
13
13
  s.default_executable = %q{hoof}
14
14
  s.description = %q{Hoof is linux variant of pow. It's based on nss, eventmachine and unicorn}
15
15
  s.email = %q{kinwizard@gmail.com}
@@ -56,7 +56,7 @@ Gem::Specification.new do |s|
56
56
  s.add_runtime_dependency(%q<daemons>, [">= 0"])
57
57
  s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
58
58
  s.add_runtime_dependency(%q<unicorn>, [">= 0"])
59
- s.add_runtime_dependency(%q<http_parser>, [">= 0"])
59
+ s.add_runtime_dependency(%q<eventmachine_httpserver>, [">= 0"])
60
60
  s.add_runtime_dependency(%q<thor>, [">= 0"])
61
61
  s.add_development_dependency(%q<shoulda>, [">= 0"])
62
62
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -66,7 +66,7 @@ Gem::Specification.new do |s|
66
66
  s.add_dependency(%q<daemons>, [">= 0"])
67
67
  s.add_dependency(%q<eventmachine>, [">= 0"])
68
68
  s.add_dependency(%q<unicorn>, [">= 0"])
69
- s.add_dependency(%q<http_parser>, [">= 0"])
69
+ s.add_dependency(%q<eventmachine_httpserver>, [">= 0"])
70
70
  s.add_dependency(%q<thor>, [">= 0"])
71
71
  s.add_dependency(%q<shoulda>, [">= 0"])
72
72
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -77,7 +77,7 @@ Gem::Specification.new do |s|
77
77
  s.add_dependency(%q<daemons>, [">= 0"])
78
78
  s.add_dependency(%q<eventmachine>, [">= 0"])
79
79
  s.add_dependency(%q<unicorn>, [">= 0"])
80
- s.add_dependency(%q<http_parser>, [">= 0"])
80
+ s.add_dependency(%q<eventmachine_httpserver>, [">= 0"])
81
81
  s.add_dependency(%q<thor>, [">= 0"])
82
82
  s.add_dependency(%q<shoulda>, [">= 0"])
83
83
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -1,6 +1,6 @@
1
1
  require 'eventmachine'
2
2
  require 'unicorn/launcher'
3
- require 'http/parser'
3
+ require 'evma_httpserver'
4
4
 
5
5
  require 'hoof/http_server'
6
6
  require 'hoof/https_server'
@@ -32,7 +32,7 @@ module Hoof
32
32
  D
33
33
  def init name = nil
34
34
  name ||= File.basename Dir.getwd
35
- create_link File.expand_path(File.join("~/.hoof", name)), '.'
35
+ create_link File.expand_path(File.join("~/.hoof", name)), Dir.getwd
36
36
  append_to_file 'Gemfile', "\ngem 'unicorn'"
37
37
  end
38
38
 
@@ -1,29 +1,38 @@
1
1
  module Hoof
2
2
  class HttpServer < EventMachine::Connection
3
+ include EventMachine::HttpServer
3
4
 
4
- def receive_data data
5
- begin
6
- parser = Http::Parser.new
7
- parser.parse data
5
+ def post_init
6
+ super
7
+ no_environment_strings
8
+ @buffer = ''
9
+ end
8
10
 
9
- host = parser.headers["HOST"].gsub(/:\d+$/, '')
11
+ def receive_data data
12
+ @buffer << data
13
+ super
14
+ end
10
15
 
16
+ def process_http_request
17
+ p 'DATA'
18
+ p @buffer
19
+ begin
20
+ host = @http_headers.scan(/Host:\s*([-a-zA-z.]*)\000/)[0][0].gsub(/:\d+$/, '')
11
21
  close_connection and return unless host =~ /.dev$/
12
22
 
13
23
  name = host.gsub(/.dev$/, '')
14
- path = parser.path.split('?', 2)[0]
15
24
  application = Hoof.find name
16
25
 
17
26
  if application
18
- if application.static_file? path
19
- puts "Serve static #{host}#{parser.path}"
20
- send_data application.serve_static(path)
27
+ if application.static_file? @http_path_info
28
+ puts "Serve static #{host}#{@http_request_uri}"
29
+ send_data application.serve_static(@http_path_info)
21
30
  close_connection_after_writing
22
31
  else
23
32
  application.start
24
- puts "Serve #{host}#{parser.path}"
33
+ puts "Serve #{host}#{@http_request_uri}"
25
34
  EventMachine.defer(proc {
26
- application.serve data
35
+ application.serve @buffer
27
36
  }, proc { |result|
28
37
  send_data result
29
38
  close_connection_after_writing
@@ -2,6 +2,7 @@ module Hoof
2
2
  class HttpsServer < HttpServer
3
3
 
4
4
  def post_init
5
+ super
5
6
  start_tls
6
7
  end
7
8
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoof
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - pyromaniac
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-17 00:00:00 +04:00
18
+ date: 2011-06-08 00:00:00 +04:00
19
19
  default_executable: hoof
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -73,7 +73,7 @@ dependencies:
73
73
  requirement: *id004
74
74
  prerelease: false
75
75
  type: :runtime
76
- name: http_parser
76
+ name: eventmachine_httpserver
77
77
  - !ruby/object:Gem::Dependency
78
78
  version_requirements: &id005 !ruby/object:Gem::Requirement
79
79
  none: false