net-http-server 0.2.0 → 0.2.1
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.
- data/ChangeLog.md +7 -0
- data/lib/net/http/server/chunked_stream.rb +1 -1
- data/lib/net/http/server/parser.rb +8 -9
- data/lib/net/http/server/requests.rb +3 -8
- data/lib/net/http/server/version.rb +1 -1
- data/spec/net/http/server/parser_spec.rb +7 -7
- data/spec/net/http/server/requests_spec.rb +0 -14
- metadata +11 -11
data/ChangeLog.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
### 0.2.1 / 2011-10-14
|
2
|
+
|
3
|
+
* Adjusted {Net::HTTP::Server::Parser} to include the leading `/` in the
|
4
|
+
`:path`.
|
5
|
+
* Use `String#replace` to clear the buffer passed to
|
6
|
+
{Net::HTTP::Server::ChunkedStream#read}.
|
7
|
+
|
1
8
|
### 0.2.0 / 2011-08-23
|
2
9
|
|
3
10
|
* Added support for handling Streams and Chunked Transfer-Encoding:
|
@@ -86,23 +86,22 @@ module Net
|
|
86
86
|
rule(:params) { param >> (str(';') >> param).repeat }
|
87
87
|
rule(:frag) { (uchar | reserved).repeat }
|
88
88
|
|
89
|
-
rule(:
|
90
|
-
path.maybe.as(:path) >>
|
89
|
+
rule(:uri_path) {
|
90
|
+
(str('/').maybe >> path.maybe).as(:path) >>
|
91
91
|
(str(';') >> params.as(:params)).maybe >>
|
92
92
|
(str('?') >> query_string.as(:query)).maybe >>
|
93
93
|
(str('#') >> frag.as(:fragment)).maybe
|
94
94
|
}
|
95
|
-
rule(:absolute_path) { str('/').repeat(1) >> relative_path }
|
96
95
|
|
97
|
-
rule(:
|
96
|
+
rule(:uri) {
|
98
97
|
scheme.as(:scheme) >> str(':') >> str('//').maybe >>
|
99
98
|
(user_info.as(:user_info) >> str('@')).maybe >>
|
100
99
|
host_name.as(:host) >>
|
101
100
|
(str(':') >> digits.as(:port)).maybe >>
|
102
|
-
|
101
|
+
uri_path
|
103
102
|
}
|
104
103
|
|
105
|
-
rule(:request_uri) { str('*') |
|
104
|
+
rule(:request_uri) { str('*') | uri | uri_path }
|
106
105
|
|
107
106
|
#
|
108
107
|
# HTTP Elements
|
@@ -112,9 +111,9 @@ module Net
|
|
112
111
|
rule(:version_number) { digits >> str('.') >> digits }
|
113
112
|
rule(:http_version) { str('HTTP/') >> version_number.as(:version) }
|
114
113
|
rule(:request_line) {
|
115
|
-
request_method.as(:method) >>
|
116
|
-
|
117
|
-
|
114
|
+
request_method.as(:method) >> str(' ') >>
|
115
|
+
request_uri.as(:uri) >> str(' ') >>
|
116
|
+
http_version
|
118
117
|
}
|
119
118
|
|
120
119
|
rule(:header_name) { (str(':').absnt? >> token).repeat(1) }
|
@@ -65,7 +65,8 @@ module Net
|
|
65
65
|
def normalize_uri(request)
|
66
66
|
uri = request[:uri]
|
67
67
|
|
68
|
-
|
68
|
+
case uri
|
69
|
+
when Hash
|
69
70
|
if uri[:scheme]
|
70
71
|
uri[:port] = unless uri[:port]
|
71
72
|
DEFAULT_PORTS[uri[:scheme]]
|
@@ -73,13 +74,7 @@ module Net
|
|
73
74
|
uri[:port].to_i
|
74
75
|
end
|
75
76
|
end
|
76
|
-
|
77
|
-
unless uri[:path]
|
78
|
-
uri[:path] = '/'
|
79
|
-
else
|
80
|
-
uri[:path].insert(0,'/')
|
81
|
-
end
|
82
|
-
elsif uri == '*'
|
77
|
+
when '*'
|
83
78
|
request[:uri] = {}
|
84
79
|
end
|
85
80
|
end
|
@@ -26,26 +26,26 @@ describe Net::HTTP::Server::Parser do
|
|
26
26
|
it "should not confuse the '/*' path with '*'" do
|
27
27
|
request = subject.parse("OPTIONS /* HTTP/1.1\r\n\r\n")
|
28
28
|
|
29
|
-
request[:uri][:path].should == '
|
29
|
+
request[:uri][:path].should == '/*'
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should parse absolute paths" do
|
33
33
|
request = subject.parse("GET /absolute/path HTTP/1.1\r\n\r\n")
|
34
34
|
|
35
|
-
request[:uri][:path].should == 'absolute/path'
|
35
|
+
request[:uri][:path].should == '/absolute/path'
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should parse the params in the path" do
|
39
39
|
request = subject.parse("GET /path;q=1;p=2 HTTP/1.1\r\n\r\n")
|
40
40
|
|
41
|
-
request[:uri][:path].should == 'path'
|
41
|
+
request[:uri][:path].should == '/path'
|
42
42
|
request[:uri][:params].should == 'q=1;p=2'
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should parse the query-string in the path" do
|
46
46
|
request = subject.parse("GET /path?q=1&p=2 HTTP/1.1\r\n\r\n")
|
47
47
|
|
48
|
-
request[:uri][:path].should == 'path'
|
48
|
+
request[:uri][:path].should == '/path'
|
49
49
|
request[:uri][:query].should == 'q=1&p=2'
|
50
50
|
end
|
51
51
|
|
@@ -55,7 +55,7 @@ describe Net::HTTP::Server::Parser do
|
|
55
55
|
request[:uri][:scheme].should == 'http'
|
56
56
|
request[:uri][:host].should == 'www.example.com'
|
57
57
|
request[:uri][:port].should == '8080'
|
58
|
-
request[:uri][:path].should == 'path'
|
58
|
+
request[:uri][:path].should == '/path'
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should parse non-http URIs" do
|
@@ -64,7 +64,7 @@ describe Net::HTTP::Server::Parser do
|
|
64
64
|
request[:uri][:scheme].should == 'xmpp'
|
65
65
|
request[:uri][:user_info].should == 'alice:secret'
|
66
66
|
request[:uri][:host].should == 'example.com'
|
67
|
-
request[:uri][:path].should == 'path'
|
67
|
+
request[:uri][:path].should == '/path'
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should parse the HTTP version" do
|
@@ -83,7 +83,7 @@ describe Net::HTTP::Server::Parser do
|
|
83
83
|
request = subject.parse("GET / HTTP/1.1\r\n\r\n")
|
84
84
|
|
85
85
|
request[:method].should == 'GET'
|
86
|
-
request[:uri][:path].should
|
86
|
+
request[:uri][:path].should == '/'
|
87
87
|
request[:version].should == '1.1'
|
88
88
|
end
|
89
89
|
end
|
@@ -52,20 +52,6 @@ describe Net::HTTP::Server::Requests do
|
|
52
52
|
request[:uri][:port].should == 80
|
53
53
|
end
|
54
54
|
|
55
|
-
it "should default :path to '/'" do
|
56
|
-
request = {:uri => {:path => nil}}
|
57
|
-
normalize_uri(request)
|
58
|
-
|
59
|
-
request[:uri][:path].should == '/'
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should ensure that the path begins with a '/'" do
|
63
|
-
request = {:uri => {:path => 'foo'}}
|
64
|
-
normalize_uri(request)
|
65
|
-
|
66
|
-
request[:uri][:path].should == '/foo'
|
67
|
-
end
|
68
|
-
|
69
55
|
it "should replace a '*' URI with an empty Hash" do
|
70
56
|
request = {:uri => '*'}
|
71
57
|
normalize_uri(request)
|
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.
|
4
|
+
version: 0.2.1
|
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-
|
12
|
+
date: 2011-10-15 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parslet
|
16
|
-
requirement: &
|
16
|
+
requirement: &16637300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16637300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: ore-tasks
|
27
|
-
requirement: &
|
27
|
+
requirement: &16636440 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.4'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *16636440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &16635800 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '2.4'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *16635800
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &16635320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 0.6.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *16635320
|
58
58
|
description: A Rack compatible pure Ruby HTTP Server.
|
59
59
|
email: postmodern.mod3@gmail.com
|
60
60
|
executables: []
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
|
-
rubygems_version: 1.8.
|
119
|
+
rubygems_version: 1.8.10
|
120
120
|
signing_key:
|
121
121
|
specification_version: 3
|
122
122
|
summary: A pure Ruby HTTP Server
|