net-http-server 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,12 @@
1
+ ### 0.2.2 / 2012-09-08
2
+
3
+ * Added an example `rackup` command.
4
+
5
+ #### Parser
6
+
7
+ * Fixed the rule for escaped unicode characters (`%uXXXX`).
8
+ * Added a rule for escaped characters (`%XX`).
9
+
1
10
  ### 0.2.1 / 2011-10-14
2
11
 
3
12
  * Adjusted {Net::HTTP::Server::Parser} to include the leading `/` in the
data/README.md CHANGED
@@ -35,6 +35,10 @@ Use it with Rack:
35
35
 
36
36
  Rack::Handler::HTTP.run app
37
37
 
38
+ Using it with `rackup`:
39
+
40
+ $ rackup -s HTTP
41
+
38
42
  ## Requirements
39
43
 
40
44
  * [parslet](http://rubygems.org/gems/parslet) ~> 1.0
data/Rakefile CHANGED
@@ -2,13 +2,13 @@ require 'rubygems'
2
2
  require 'rake'
3
3
 
4
4
  begin
5
- gem 'ore-tasks', '~> 0.4'
6
- require 'ore/tasks'
5
+ gem 'rubygems-tasks', '~> 0.1'
6
+ require 'rubygems/tasks'
7
7
 
8
- Ore::Tasks.new
8
+ Gem::Tasks.new
9
9
  rescue LoadError => e
10
10
  warn e.message
11
- warn "Run `gem install ore-tasks` to install 'ore/tasks'."
11
+ warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
12
12
  end
13
13
 
14
14
  begin
@@ -25,7 +25,7 @@ task :test => :spec
25
25
  task :default => :spec
26
26
 
27
27
  begin
28
- gem 'yard', '~> 0.6.0'
28
+ gem 'yard', '~> 0.8'
29
29
  require 'yard'
30
30
 
31
31
  YARD::Rake::YardocTask.new
@@ -11,6 +11,6 @@ dependencies:
11
11
  parslet: ~> 1.0
12
12
 
13
13
  development_dependencies:
14
- ore-tasks: ~> 0.4
14
+ rubygems-tasks: ~> 0.1
15
15
  rspec: ~> 2.4
16
- yard: ~> 0.6.0
16
+ yard: ~> 0.8
@@ -43,8 +43,9 @@ module Net
43
43
  }
44
44
 
45
45
  rule(:unreserved) { alpha | digit | safe | extra | national }
46
- rule(:escape) { str("%u").maybe >> xdigit >> xdigit }
47
- rule(:uchar) { unreserved | escape | sorta_safe }
46
+ rule(:uescape) { str("%u") >> xdigit >> xdigit >> xdigit >> xdigit }
47
+ rule(:escape) { str("%") >> xdigit >> xdigit }
48
+ rule(:uchar) { unreserved | uescape | escape | sorta_safe }
48
49
  rule(:pchar) { uchar | charset(':', '@', '&', '=', '+') }
49
50
  rule(:separators) {
50
51
  lws | charset(
@@ -7,7 +7,7 @@ module Net
7
7
  # Default ports for common URI schemes
8
8
  DEFAULT_PORTS = {
9
9
  'https' => 443,
10
- 'http' => 80
10
+ 'http' => 80
11
11
  }
12
12
 
13
13
  protected
@@ -91,7 +91,7 @@ module Net
91
91
 
92
92
  unless headers.empty?
93
93
  headers.each do |header|
94
- name = header[:name].to_s
94
+ name = header[:name].to_s
95
95
  value = header[:value].to_s
96
96
 
97
97
  if normalized_headers.has_key?(name)
@@ -87,7 +87,7 @@ module Net
87
87
  # @param [IO] stream
88
88
  # The stream to write the headers back to.
89
89
  #
90
- # @param [Hash{String => [String, Time, Array<String>}] headers
90
+ # @param [Hash{String => String,Time,Array<String>}] headers
91
91
  # The headers of the HTTP Response.
92
92
  #
93
93
  def write_headers(stream,headers)
@@ -155,7 +155,7 @@ module Net
155
155
  # @param [Integer] status
156
156
  # The status of the HTTP Response.
157
157
  #
158
- # @param [Hash{String => [String, Time, Array<String>}] headers
158
+ # @param [Hash{String => String,Time,Array<String>}] headers
159
159
  # The headers of the HTTP Response.
160
160
  #
161
161
  # @param [#each] body
@@ -4,7 +4,7 @@ module Net
4
4
  class HTTP < Protocol
5
5
  module Server
6
6
  # net-http-server version.
7
- VERSION = '0.2.1'
7
+ VERSION = '0.2.2'
8
8
  end
9
9
  end
10
10
  end
@@ -47,10 +47,9 @@ module Rack
47
47
  # The port to listen on.
48
48
  #
49
49
  def initialize(app,options={})
50
- @app = app
50
+ @app = app
51
51
  @options = options
52
-
53
- @server = nil
52
+ @server = nil
54
53
  end
55
54
 
56
55
  #
@@ -67,8 +66,8 @@ module Rack
67
66
  #
68
67
  def run
69
68
  @server = Net::HTTP::Server::Daemon.new(
70
- :host => @options[:Host],
71
- :port => @options[:Port],
69
+ :host => @options[:Host],
70
+ :port => @options[:Port],
72
71
  :handler => self
73
72
  )
74
73
 
@@ -89,9 +88,9 @@ module Rack
89
88
  # The response status, headers and body.
90
89
  #
91
90
  def call(request,stream)
92
- request_uri = request[:uri]
91
+ request_uri = request[:uri]
93
92
  remote_address = stream.socket.remote_address
94
- local_address = stream.socket.local_address
93
+ local_address = stream.socket.local_address
95
94
 
96
95
  env = {}
97
96
 
@@ -105,16 +104,16 @@ module Rack
105
104
  env['rack.url_scheme'] = request_uri[:scheme].to_s
106
105
  end
107
106
 
108
- env['SERVER_NAME'] = local_address.getnameinfo[0]
109
- env['SERVER_PORT'] = local_address.ip_port.to_s
107
+ env['SERVER_NAME'] = local_address.getnameinfo[0]
108
+ env['SERVER_PORT'] = local_address.ip_port.to_s
110
109
  env['SERVER_PROTOCOL'] = "HTTP/#{request[:http_version]}"
111
110
 
112
111
  env['REMOTE_ADDR'] = remote_address.ip_address
113
112
  env['REMOTE_PORT'] = remote_address.ip_port.to_s
114
113
 
115
114
  env['REQUEST_METHOD'] = request[:method].to_s
116
- env['PATH_INFO'] = request_uri.fetch(:path,'*').to_s
117
- env['QUERY_STRING'] = request_uri[:query_string].to_s
115
+ env['PATH_INFO'] = request_uri.fetch(:path,'*').to_s
116
+ env['QUERY_STRING'] = request_uri[:query_string].to_s
118
117
 
119
118
  # add the headers
120
119
  request[:headers].each do |name,value|
@@ -2,24 +2,22 @@ require 'spec_helper'
2
2
  require 'net/http/server/daemon'
3
3
 
4
4
  describe Net::HTTP::Server::Daemon do
5
- subject { Net::HTTP::Server::Daemon }
5
+ subject { described_class }
6
6
 
7
- describe "new" do
8
- it "should have a default host" do
9
- daemon = subject.new { |request,socket| }
7
+ describe "#initialize" do
8
+ subject { described_class.new { |request,response| } }
10
9
 
11
- daemon.host.should_not be_nil
10
+ it "should have a default host" do
11
+ subject.host.should_not be_nil
12
12
  end
13
13
 
14
14
  it "should have a default port" do
15
- daemon = subject.new { |request,socket| }
16
-
17
- daemon.port.should_not be_nil
15
+ subject.port.should_not be_nil
18
16
  end
19
17
 
20
18
  it "should require a HTTP Request handler" do
21
19
  lambda {
22
- subject.new
20
+ described_class.new
23
21
  }.should raise_error
24
22
  end
25
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-http-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-15 00:00:00.000000000Z
12
+ date: 2012-09-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parslet
16
- requirement: &16637300 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,31 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16637300
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
25
30
  - !ruby/object:Gem::Dependency
26
- name: ore-tasks
27
- requirement: &16636440 !ruby/object:Gem::Requirement
31
+ name: rubygems-tasks
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
31
36
  - !ruby/object:Gem::Version
32
- version: '0.4'
37
+ version: '0.1'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *16636440
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0.1'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &16635800 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,18 +53,28 @@ dependencies:
43
53
  version: '2.4'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *16635800
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.4'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: yard
49
- requirement: &16635320 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
53
68
  - !ruby/object:Gem::Version
54
- version: 0.6.0
69
+ version: '0.8'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *16635320
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '0.8'
58
78
  description: A Rack compatible pure Ruby HTTP Server.
59
79
  email: postmodern.mod3@gmail.com
60
80
  executables: []
@@ -116,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
136
  version: '0'
117
137
  requirements: []
118
138
  rubyforge_project:
119
- rubygems_version: 1.8.10
139
+ rubygems_version: 1.8.23
120
140
  signing_key:
121
141
  specification_version: 3
122
142
  summary: A pure Ruby HTTP Server