akito19/rack-joint

Support HTTPS

ybiquitous opened this issue ยท 2 comments

Hi! Thanks for this nice library! ๐Ÿ˜„

I tried whether HTTPS is supported, but failed... ๐Ÿ˜“

diff --git a/test/rack/joint_test.rb b/test/rack/joint_test.rb
index e7546a5..2ddccfc 100644
--- a/test/rack/joint_test.rb
+++ b/test/rack/joint_test.rb
@@ -23,9 +23,9 @@ class JointTest < MiniTest::Test
     end
 
     def test_joint
-      get '/dogs/bark.html', {}, 'HTTP_HOST' => 'example.com'
+      get '/dogs/bark.html', {}, 'HTTP_HOST' => 'example.com', 'HTTPS' => 'on'
       assert_equal 301, last_response.status
-      assert_equal 'http://example.org/bowwow/woof', last_response['location']
+      assert_equal 'https://example.org/bowwow/woof', last_response['location']
 
       get '/cats/meow.html', {}, 'HTTP_HOST' => 'example.com'
       assert_equal 302, last_response.status
$ rake
Run options: --seed 46456

# Running:

.....F.

Finished in 0.036273s, 192.9810 runs/s, 441.0994 assertions/s.

  1) Failure:
JointTest::MultiplePathsTest#test_joint [/Users/koba/git/ybiquitous/rack-joint/test/rack/joint_test.rb:28]:
--- expected
+++ actual
@@ -1 +1 @@
-"https://example.org/bowwow/woof"
+"http://example.org/bowwow/woof"


7 runs, 16 assertions, 1 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1)
...

Maybe I think that it will work if using Rack::Request#scheme, so what do you think about this idea?

https://github.com/rack/rack/blob/b146a0166fba0343f78df72a95df01be9c5d7b57/lib/rack/request.rb#L194

Thanks.

Absolutely. I'm trying to support it.

Great! ๐Ÿคฉ