webmachine 1.3.0 → 1.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -1
- data/Gemfile +1 -0
- data/lib/webmachine/adapters/rack.rb +1 -1
- data/lib/webmachine/request.rb +28 -12
- data/lib/webmachine/spec/adapter_lint.rb +10 -14
- data/lib/webmachine/version.rb +1 -1
- data/spec/webmachine/adapters/rack_spec.rb +21 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 280847c579eab4ad41bfd4ce4d0471cf56a0c7db
|
4
|
+
data.tar.gz: 521c6386b2202a050ed8dea00b5c3ee2d152a259
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9e961c7352e6857dddd1f95206d566261d97340f8304fe7f73e021d04a3adf1f47a701d41635bff6c55db65be22561c0ea87f29ddcd6be6751d32a8237d2b20
|
7
|
+
data.tar.gz: 6f865e4318a96693486f4b454a932d8970f22bd6b008a90a41fe62cc92e55af7e346889026fac8bff3d4c072e2eaa7d9371f4f27dc15171f7cf6a25bc2c3599e
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,39 @@
|
|
1
1
|
### HEAD
|
2
2
|
|
3
|
-
|
3
|
+
### 1.3.1 January 15, 2015
|
4
|
+
|
5
|
+
* Fixed URI construction, including handling IPv6 addresses, when the
|
6
|
+
adapter did not supply a complete hostname.
|
7
|
+
* Removed dependency of Rack Adapter on REQUEST_INFO rack environment
|
8
|
+
variable which was not always present.
|
9
|
+
* Use IPAddr instead of Addrinfo as rbx does not support Addrinfo.
|
10
|
+
|
11
|
+
### 1.3.0 January 3, 2015
|
12
|
+
|
13
|
+
1.3.0 is a feature and bugfix release that removes two adapters,
|
14
|
+
reduces memory usage, fixes bugs, and includes a bunch of new
|
15
|
+
documentation. Thank you to our new contributor @rpag!
|
16
|
+
|
17
|
+
* Greatly reduced per-request garbage by freezing commonly used
|
18
|
+
Strings and Regexps into constants.
|
19
|
+
* Tutorial/example documentation was extracted from the README and
|
20
|
+
extended in the `documentation` directory.
|
21
|
+
* HTTPkit adapter was added.
|
22
|
+
* Hatetepe and Mongrel adapters were removed and adapters no longer
|
23
|
+
install interrupt handlers.
|
24
|
+
* The "splat" matcher in path specifications is now a Symbol `:*`
|
25
|
+
rather than a String `"*"`. Using the String version will result in
|
26
|
+
a deprecation warning.
|
27
|
+
* Requests with If-None-Match where the resource does not supply an
|
28
|
+
ETag will no longer respond with 412 or 500, but follow the success
|
29
|
+
path.
|
30
|
+
* Path fragments are now decoded.
|
31
|
+
* Simplified the interaction between the decision FSM and tracing.
|
32
|
+
* Updated specs to use RSpec 3.
|
33
|
+
* Improved handling of IO.copy_stream on Rack servers.
|
34
|
+
* Updated the Reel adapter.
|
35
|
+
* Exposed Application instance to the Adapter.
|
36
|
+
* Decode the value of the header 'Content-MD5' as base64-encoded string.
|
4
37
|
|
5
38
|
### 1.2.2 January 8, 2014
|
6
39
|
|
data/Gemfile
CHANGED
data/lib/webmachine/request.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'cgi'
|
2
2
|
require 'forwardable'
|
3
3
|
require 'webmachine/constants'
|
4
|
+
require 'ipaddr'
|
4
5
|
|
5
6
|
module Webmachine
|
6
7
|
# Request represents a single HTTP request sent from a client. It
|
@@ -33,11 +34,11 @@ module Webmachine
|
|
33
34
|
if m =~ HTTP_HEADERS_MATCH
|
34
35
|
# Access headers more easily as underscored methods.
|
35
36
|
header_name = m.to_s.tr(UNDERSCORE, DASH)
|
36
|
-
if (header_value = headers[header_name])
|
37
|
+
if (header_value = @headers[header_name])
|
37
38
|
# Make future lookups faster.
|
38
39
|
self.class.class_eval <<-RUBY, __FILE__, __LINE__
|
39
40
|
def #{m}
|
40
|
-
headers["#{header_name}"]
|
41
|
+
@headers["#{header_name}"]
|
41
42
|
end
|
42
43
|
RUBY
|
43
44
|
end
|
@@ -165,19 +166,34 @@ module Webmachine
|
|
165
166
|
|
166
167
|
private
|
167
168
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
169
|
+
IPV6_MATCH = /\A\[(?<address> .* )\]:(?<port> \d+ )\z/x.freeze # string like "[::1]:80"
|
170
|
+
HOST_MATCH = /\A(?<host> [^:]+ ):(?<port> \d+ )\z/x.freeze # string like "www.example.com:80"
|
171
|
+
|
172
|
+
def parse_host(uri, host_string)
|
173
|
+
# Split host and port number from string.
|
174
|
+
case host_string
|
175
|
+
when IPV6_MATCH
|
176
|
+
uri.host = IPAddr.new($~[:address], Socket::AF_INET6).to_s
|
177
|
+
uri.port = $~[:port].to_i
|
178
|
+
when HOST_MATCH
|
179
|
+
uri.host = $~[:host]
|
180
|
+
uri.port = $~[:port].to_i
|
181
|
+
else # string with no port number
|
182
|
+
uri.host = host_string
|
183
|
+
end
|
173
184
|
|
174
|
-
|
175
|
-
|
185
|
+
uri
|
186
|
+
end
|
176
187
|
|
177
|
-
|
178
|
-
uri
|
188
|
+
def build_uri(uri, headers)
|
189
|
+
uri = URI(uri)
|
190
|
+
uri.port ||= 80
|
191
|
+
uri.scheme ||= HTTP
|
192
|
+
if uri.host
|
193
|
+
return uri
|
194
|
+
end
|
179
195
|
|
180
|
-
|
196
|
+
parse_host(uri, headers.fetch(HOST))
|
181
197
|
end
|
182
198
|
|
183
199
|
end # class Request
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "webmachine/spec/test_resource"
|
1
|
+
require "webmachine/spec/test_resource"
|
2
2
|
require "net/http"
|
3
3
|
|
4
4
|
shared_examples_for :adapter_lint do
|
@@ -53,20 +53,16 @@ shared_examples_for :adapter_lint do
|
|
53
53
|
expect(response.body).to eq("http://#{address}:#{port}/test")
|
54
54
|
end
|
55
55
|
|
56
|
-
context do
|
57
|
-
|
56
|
+
# context do
|
57
|
+
# let(:address) { "::1" }
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
response = client.request(request)
|
67
|
-
expect(response.body).to eq("http://[#{address}]:#{port}/test")
|
68
|
-
end
|
69
|
-
end
|
59
|
+
# it "provides the IPv6 request URI" do
|
60
|
+
# request = Net::HTTP::Get.new("/test")
|
61
|
+
# request["Accept"] = "test/response.request_uri"
|
62
|
+
# response = client.request(request)
|
63
|
+
# expect(response.body).to eq("http://[#{address}]:#{port}/test")
|
64
|
+
# end
|
65
|
+
# end
|
70
66
|
|
71
67
|
it "provides a string-like request body" do
|
72
68
|
request = Net::HTTP::Put.new("/test")
|
data/lib/webmachine/version.rb
CHANGED
@@ -2,6 +2,7 @@ require 'webmachine/adapter'
|
|
2
2
|
require 'webmachine/adapters/rack'
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'webmachine/spec/adapter_lint'
|
5
|
+
require 'rack/test'
|
5
6
|
|
6
7
|
describe Webmachine::Adapters::Rack do
|
7
8
|
it_should_behave_like :adapter_lint do
|
@@ -34,3 +35,23 @@ describe Webmachine::Adapters::Rack::RackResponse do
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
38
|
+
|
39
|
+
describe Webmachine::Adapters::Rack do
|
40
|
+
let(:app) do
|
41
|
+
Webmachine::Application.new do |app|
|
42
|
+
app.add_route(["test"], Test::Resource)
|
43
|
+
app.configure do | config |
|
44
|
+
config.adapter = :Rack
|
45
|
+
end
|
46
|
+
end.adapter
|
47
|
+
end
|
48
|
+
|
49
|
+
context "using Rack::Test" do
|
50
|
+
include Rack::Test::Methods
|
51
|
+
|
52
|
+
it "provides the full request URI" do
|
53
|
+
rack_response = get "test", nil, {"HTTP_ACCEPT" => "test/response.request_uri"}
|
54
|
+
expect(rack_response.body).to eq "http://example.org/test"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Cribbs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
196
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.
|
197
|
+
rubygems_version: 2.2.2
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: webmachine is a toolkit for building HTTP applications,
|