async-http 0.50.3 → 0.50.4

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
  SHA256:
3
- metadata.gz: c153c0c4ab78ac5723d7e92c0210913fd89009503149a33142df4d262dc7e647
4
- data.tar.gz: 8922a6fe85a00d84735b7d8bb68a876d6465a57a5c76cfc3b943c82fa8f69c64
3
+ metadata.gz: d28849525da21bccd07dc93b7b19a59f734cc35bfdfbef568fd73d00be2677ce
4
+ data.tar.gz: efc93512775ec6c66422b3c24cb178957e7826959a69536c5999f07bbd8dd242
5
5
  SHA512:
6
- metadata.gz: b022b86258ed5322e6e5f5ad14f78d0eeabde46a4afa11bd2307b6b00c20995aee9795fa72d58743bbdb29b36009d73c75e782b42962f87d59b5dc4eef9c71d3
7
- data.tar.gz: a652c97a5e238bf77effee3d8206807a03139674e328863d614dec53bf4ebd7be72946b9854a9ac84dafb9691e88ac3394d97fe3ce4d28bbc8852c6e917fcd6a
6
+ metadata.gz: 5f6e167dde14dd86e25253127e50163cc956c83983da54033b31825dacb3f2257b4bc53aad7ff0c435a224456ce0a00e79f2180c36cf0992ce3e2fdf4332ec7d
7
+ data.tar.gz: d9c3ebf70b76f6eb2b3b3653c52be36f766633ccd10158fa8565113771720243086f29cc2abae2230236f0431f39b90e7d7c9a91daf4cb96323f884e1ca26921
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  An asynchronous client and server implementation of HTTP/1.0, HTTP/1.1 and HTTP/2 including TLS. Support for streaming requests and responses. Built on top of [async] and [async-io]. [falcon] provides a rack-compatible server.
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/socketry/async-http.svg)](http://travis-ci.org/socketry/async-http)
5
+ [![Build Status](https://travis-ci.com/socketry/async-http.svg?branch=master)](https://travis-ci.com/socketry/async-http)
6
6
  [![Code Climate](https://codeclimate.com/github/socketry/async-http.svg)](https://codeclimate.com/github/socketry/async-http)
7
7
  [![Coverage Status](https://coveralls.io/repos/socketry/async-http/badge.svg)](https://coveralls.io/r/socketry/async-http)
8
8
 
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency("async-io", "~> 1.27.0")
22
22
  spec.add_dependency("async-pool", "~> 0.2")
23
23
 
24
- spec.add_dependency("protocol-http", "~> 0.14.0")
24
+ spec.add_dependency("protocol-http", "~> 0.14.1")
25
25
  spec.add_dependency("protocol-http1", "~> 0.10.0")
26
26
  spec.add_dependency("protocol-http2", "~> 0.10.0")
27
27
 
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Async
24
24
  module HTTP
25
- VERSION = "0.50.3"
25
+ VERSION = "0.50.4"
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.50.3
4
+ version: 0.50.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-05 00:00:00.000000000 Z
11
+ date: 2020-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.14.0
61
+ version: 0.14.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.14.0
68
+ version: 0.14.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: protocol-http1
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -244,7 +244,6 @@ files:
244
244
  - lib/async/http/body/slowloris.rb
245
245
  - lib/async/http/body/stream.rb
246
246
  - lib/async/http/body/writable.rb
247
- - lib/async/http/cache.rb
248
247
  - lib/async/http/client.rb
249
248
  - lib/async/http/endpoint.rb
250
249
  - lib/async/http/internet.rb
@@ -1,153 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
-
23
- require 'async/http/client'
24
- require 'protocol/http/headers'
25
- require 'protocol/http/middleware'
26
- require 'async/clock'
27
-
28
- require 'protocol/http/body/cacheable'
29
-
30
- module Async
31
- module HTTP
32
- class Cache < ::Protocol::HTTP::Middleware
33
- CACHE_CONTROL = 'cache-control'
34
-
35
- class Response < ::Protocol::HTTP::Response
36
- def initialize(response, body)
37
- @generated_at = Async::Clock.now
38
-
39
- super(
40
- response.version,
41
- response.status,
42
- response.headers.dup,
43
- body,
44
- response.protocol
45
- )
46
-
47
- @max_age = @headers[CACHE_CONTROL]&.max_age
48
- end
49
-
50
- def cachable?
51
- if cache_control = @headers[CACHE_CONTROL]
52
- if cache_control.private?
53
- return false
54
- end
55
-
56
- if cache_control.public?
57
- return true
58
- end
59
- end
60
- end
61
-
62
- attr :generated_at
63
-
64
- def age
65
- Async::Clock.now - @generated_at
66
- end
67
-
68
- def expired?
69
- self.age > @max_age
70
- end
71
-
72
- def dup
73
- dup = super
74
-
75
- dup.body = @body.dup
76
- dup.headers = @headers.dup
77
-
78
- return dup
79
- end
80
- end
81
-
82
- def initialize(app, responses = {})
83
- super(app)
84
-
85
- @count = 0
86
-
87
- @responses = {}
88
- end
89
-
90
- attr :count
91
-
92
- def key(request)
93
- [request.authority, request.method, request.path]
94
- end
95
-
96
- def cachable?(request)
97
- # We don't support caching requests which have a body:
98
- if request.body
99
- return false
100
- end
101
-
102
- # We can't cache upgraded requests:
103
- if request.protocol
104
- return false
105
- end
106
-
107
- # We only support caching GET and HEAD requests:
108
- if request.method == 'GET' || request.method == 'HEAD'
109
- return true
110
- end
111
-
112
- # Otherwise, we can't cache it:
113
- return false
114
- end
115
-
116
- def wrap(request, key, response)
117
- Body::Cacheable.wrap(response) do |response, body|
118
- response = Response.new(response, body)
119
-
120
- if response.cachable?
121
- @responses[key] = response
122
- end
123
- end
124
-
125
- return response
126
- end
127
-
128
- def call(request)
129
- key = self.key(request)
130
-
131
- if response = @responses[key]
132
- Async.logger.debug(self) {"Cache hit for #{key}..."}
133
- @count += 1
134
-
135
- if response.expired?
136
- @responses.delete(key)
137
- Async.logger.debug(self) {"Cache expired for #{key}..."}
138
- else
139
- # Create a dup of the response:
140
- return response.dup
141
- end
142
- end
143
-
144
- if cachable?(request)
145
- Async.logger.debug(self) {"Updating cache for #{key}..."}
146
- return wrap(request, key, super)
147
- else
148
- return super
149
- end
150
- end
151
- end
152
- end
153
- end