pronghorn 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pronghorn/connection.rb +2 -1
- data/lib/pronghorn/request.rb +6 -8
- data/lib/pronghorn/server.rb +2 -2
- data/lib/pronghorn/version.rb +1 -1
- metadata +3 -3
data/lib/pronghorn/connection.rb
CHANGED
@@ -20,6 +20,7 @@ module Pronghorn
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def process
|
23
|
+
@request.body.rewind
|
23
24
|
send_response(process_request)
|
24
25
|
end
|
25
26
|
|
@@ -28,7 +29,7 @@ module Pronghorn
|
|
28
29
|
"REMOTE_ADDR" => remote_address,
|
29
30
|
"SERVER_PORT" => @server.port.to_s
|
30
31
|
})
|
31
|
-
|
32
|
+
@app.call(@request.env)
|
32
33
|
end
|
33
34
|
|
34
35
|
def send_response(result)
|
data/lib/pronghorn/request.rb
CHANGED
@@ -5,8 +5,10 @@ module Pronghorn
|
|
5
5
|
|
6
6
|
attr_reader :env
|
7
7
|
|
8
|
+
attr_reader :body
|
9
|
+
|
8
10
|
PROTO_ENV = {
|
9
|
-
"SERVER_SOFTWARE".freeze => "
|
11
|
+
"SERVER_SOFTWARE".freeze => "Proghorn #{::Pronghorn::VERSION}".freeze,
|
10
12
|
"SERVER_NAME".freeze => "localhost",
|
11
13
|
"SERVER_PROTOCOL".freeze => "HTTP/1.1",
|
12
14
|
"HTTP_VERSION".freeze => "HTTP/1.1",
|
@@ -24,12 +26,8 @@ module Pronghorn
|
|
24
26
|
|
25
27
|
def initialize
|
26
28
|
@parser = Http::Parser.new
|
27
|
-
@parser.on_body = proc
|
28
|
-
|
29
|
-
end
|
30
|
-
@parser.on_headers_complete = proc do |headers|
|
31
|
-
@headers = headers
|
32
|
-
end
|
29
|
+
@parser.on_body = proc { |chunk| @body << chunk }
|
30
|
+
@parser.on_headers_complete = proc { |headers| @headers = headers }
|
33
31
|
|
34
32
|
initial_body = ''
|
35
33
|
initial_body.encode!(Encoding::ASCII_8BIT) if initial_body.respond_to?(:encode!)
|
@@ -48,7 +46,7 @@ module Pronghorn
|
|
48
46
|
})
|
49
47
|
@env["FRAGMENT"] = @parser.fragment if @parser.fragment
|
50
48
|
if @headers.key?("Content-Length")
|
51
|
-
@env["CONTENT_LENGTH"] = @headers.delete("Content-Length")
|
49
|
+
@env["CONTENT_LENGTH"] = @headers.delete("Content-Length")
|
52
50
|
end
|
53
51
|
if @headers.key?("Content-Type")
|
54
52
|
@env["CONTENT_TYPE"] = @headers.delete("Content-Type")
|
data/lib/pronghorn/server.rb
CHANGED
@@ -25,7 +25,7 @@ module Pronghorn
|
|
25
25
|
Signal.trap("TERM") { stop }
|
26
26
|
|
27
27
|
puts "Proghorn #{::Pronghorn::VERSION} starting..."
|
28
|
-
puts "* Listening on http://#{@host}:#{@port}"
|
28
|
+
puts "* Listening on http://#{@host}:#{@port} *"
|
29
29
|
|
30
30
|
EventMachine.error_handler{ |error|
|
31
31
|
puts error.message
|
@@ -39,7 +39,7 @@ module Pronghorn
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def stop
|
42
|
-
puts "* Stopping server"
|
42
|
+
puts "* Stopping server *"
|
43
43
|
return unless @running
|
44
44
|
@running = false
|
45
45
|
EventMachine.stop_server(@signature)
|
data/lib/pronghorn/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pronghorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 1.8.
|
117
|
+
rubygems_version: 1.8.23
|
118
118
|
signing_key:
|
119
119
|
specification_version: 3
|
120
120
|
summary: Minimal HTTP server for Rack apps
|