async-http 0.5.0 → 0.6.0

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: b1bb7466a7e1a7287ef68894f7c33ff15d58722e
4
- data.tar.gz: a495ad3fb1b3091ee661445bd1ff07da854b069d
3
+ metadata.gz: 013fbd13a7bf3d427d1fa5b21caff2f818050103
4
+ data.tar.gz: 8d87d03698f68f4d7d69e639ca66726463c72f31
5
5
  SHA512:
6
- metadata.gz: ca03d02a7668d33fce1c993516bd5285ec1401de89c57de77f007cb1a48da662eced1bd8670e2b2e47a4c4d968ef36b89c30193d21cb3af4d4b954392ea439a9
7
- data.tar.gz: 17cf149c4a63f7013422df65a18cf017b17a66e0842db7a6615d2bf791ba0e64f69d6ac36bd72f9f5624358e93ed67b08e716f3a6d9a0ce8f8f1955ae92afe4c
6
+ metadata.gz: 72444c8c1320f81dbedea9cf855ebc729a39989ee831d1e27633899242309ea4ab34645998c08f35b66cf41a75da58276622d4062ba3ef0f7c117e2ac4a8ccda
7
+ data.tar.gz: 4dfb58bd27fed7d8fa4d61d06049c6d4aeeeb7a930c62808f46e9aa72600a1c594602a730da5e5cef03a9779567db6cf24b98970e2c68e4ac3bea721df370834
@@ -0,0 +1,82 @@
1
+ # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'async/io/endpoint'
22
+ require 'async/io/ssl_socket'
23
+
24
+ module Async
25
+ module HTTP
26
+ class URLEndpoint < Async::IO::Endpoint
27
+ def self.parse(string, **options)
28
+ self.new(URI.parse(string), **options)
29
+ end
30
+
31
+ def address
32
+ endpoint.address
33
+ end
34
+
35
+ def secure?
36
+ ['https', 'wss'].include?(specification.scheme)
37
+ end
38
+
39
+ def default_port
40
+ secure? ? 443 : 80
41
+ end
42
+
43
+ def port
44
+ specification.port || default_port
45
+ end
46
+
47
+ def hostname
48
+ specification.hostname
49
+ end
50
+
51
+ def ssl_context
52
+ options[:ssl_context] || ::OpenSSL::SSL::SSLContext.new.tap do |context|
53
+ context.set_params
54
+ end
55
+ end
56
+
57
+ def endpoint
58
+ unless defined? @endpoint
59
+ @endpoint = Async::IO::Endpoint.tcp(hostname, port)
60
+
61
+ if secure?
62
+ # Wrap it in SSL:
63
+ @endpoint = Async::IO::SecureEndpoint.new(@endpoint,
64
+ ssl_context: ssl_context,
65
+ hostname: self.hostname
66
+ )
67
+ end
68
+ end
69
+
70
+ return @endpoint
71
+ end
72
+
73
+ def bind(*args, &block)
74
+ endpoint.bind(*args, &block)
75
+ end
76
+
77
+ def connect(*args, &block)
78
+ endpoint.connect(*args, &block)
79
+ end
80
+ end
81
+ end
82
+ end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.5.0"
23
+ VERSION = "0.6.0"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -118,6 +118,7 @@ files:
118
118
  - lib/async/http/protocol/request.rb
119
119
  - lib/async/http/protocol/response.rb
120
120
  - lib/async/http/server.rb
121
+ - lib/async/http/url_endpoint.rb
121
122
  - lib/async/http/version.rb
122
123
  homepage: https://github.com/socketry/async-http
123
124
  licenses: []