webmachine 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c535ba9701c69baab3387693d7060214271a615
4
- data.tar.gz: 2701314eb2dd27ba6af46013532b6e653f63ac95
3
+ metadata.gz: 280847c579eab4ad41bfd4ce4d0471cf56a0c7db
4
+ data.tar.gz: 521c6386b2202a050ed8dea00b5c3ee2d152a259
5
5
  SHA512:
6
- metadata.gz: 5e24dfb767ed02c92a69c8d8962dad39abb1652baeb0f7852a692cf61f5baa6fbd36ca297dfca9b10a3262579c4047b83ea6fe1861927177fa50f4e6522803d2
7
- data.tar.gz: a2cabce4143030fbec07b5ebdc65c38c1018df32fe6844a23c0ced95c1dc88e434be17c260dadb0205d6279a6c915c67c321f62665a4a4b247f1da9145d42775
6
+ metadata.gz: b9e961c7352e6857dddd1f95206d566261d97340f8304fe7f73e021d04a3adf1f47a701d41635bff6c55db65be22561c0ea87f29ddcd6be6751d32a8237d2b20
7
+ data.tar.gz: 6f865e4318a96693486f4b454a932d8970f22bd6b008a90a41fe62cc92e55af7e346889026fac8bff3d4c072e2eaa7d9371f4f27dc15171f7cf6a25bc2c3599e
@@ -1,6 +1,39 @@
1
1
  ### HEAD
2
2
 
3
- * decode the value of the header 'Content-MD5' as base64-encoded string.
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
@@ -11,6 +11,7 @@ group :test do
11
11
  gem "rspec", '~> 3.0.0'
12
12
  gem "rspec-its"
13
13
  gem "rack"
14
+ gem "rack-test"
14
15
  end
15
16
 
16
17
  group :webservers do
@@ -60,7 +60,7 @@ module Webmachine
60
60
 
61
61
  rack_req = ::Rack::Request.new env
62
62
  request = Webmachine::Request.new(rack_req.request_method,
63
- env[REQUEST_URI],
63
+ rack_req.url,
64
64
  headers,
65
65
  RequestBody.new(rack_req))
66
66
 
@@ -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
- def build_uri(uri, headers)
169
- uri = URI(uri)
170
-
171
- host, _, port = headers.fetch(HOST, "").rpartition(COLON)
172
- return uri if host.empty?
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
- host = "[#{host}]" if host.include?(COLON)
175
- port = 80 if port.empty?
185
+ uri
186
+ end
176
187
 
177
- uri.scheme = HTTP
178
- uri.host, uri.port = host, port.to_i
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
- URI.parse(uri.to_s)
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
- let(:address) { "::1" }
56
+ # context do
57
+ # let(:address) { "::1" }
58
58
 
59
- it "provides the IPv6 request URI" do
60
- if RUBY_VERSION =~ /^2\.(0|1)\./
61
- skip "Net::HTTP regression in Ruby 2.(0|1)"
62
- end
63
-
64
- request = Net::HTTP::Get.new("/test")
65
- request["Accept"] = "test/response.request_uri"
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")
@@ -1,6 +1,6 @@
1
1
  module Webmachine
2
2
  # Library version
3
- VERSION = "1.3.0".freeze
3
+ VERSION = "1.3.1".freeze
4
4
 
5
5
  # String for use in "Server" HTTP response header, which includes
6
6
  # the {VERSION}.
@@ -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.0
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-03 00:00:00.000000000 Z
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.4.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,