async-http 0.40.3 → 0.41.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/async-http.gemspec +3 -3
  4. data/examples/request.rb +3 -3
  5. data/examples/upload/client.rb +2 -2
  6. data/examples/upload/server.rb +3 -3
  7. data/lib/async/http.rb +1 -1
  8. data/lib/async/http/body.rb +2 -11
  9. data/lib/async/http/body/hijack.rb +3 -3
  10. data/lib/async/http/body/writable.rb +3 -2
  11. data/lib/async/http/client.rb +11 -10
  12. data/lib/async/http/{url_endpoint.rb → endpoint.rb} +1 -1
  13. data/lib/async/http/internet.rb +6 -6
  14. data/lib/async/http/pool.rb +1 -1
  15. data/lib/async/http/protocol/http1/client.rb +19 -8
  16. data/lib/async/http/protocol/http1/connection.rb +8 -25
  17. data/lib/async/http/protocol/http1/request.rb +10 -7
  18. data/lib/async/http/protocol/http1/response.rb +19 -3
  19. data/lib/async/http/protocol/http1/server.rb +14 -2
  20. data/lib/async/http/protocol/http10.rb +4 -0
  21. data/lib/async/http/protocol/http11.rb +4 -0
  22. data/lib/async/http/protocol/http2.rb +8 -0
  23. data/lib/async/http/protocol/http2/connection.rb +11 -2
  24. data/lib/async/http/protocol/http2/promise.rb +2 -2
  25. data/lib/async/http/protocol/http2/request.rb +17 -9
  26. data/lib/async/http/protocol/http2/response.rb +12 -6
  27. data/lib/async/http/protocol/http2/server.rb +12 -10
  28. data/lib/async/http/protocol/http2/stream.rb +1 -1
  29. data/lib/async/http/protocol/request.rb +6 -6
  30. data/lib/async/http/protocol/response.rb +5 -6
  31. data/lib/async/http/relative_location.rb +5 -4
  32. data/lib/async/http/server.rb +7 -5
  33. data/lib/async/http/statistics.rb +2 -2
  34. data/lib/async/http/version.rb +1 -1
  35. data/tasks/server.rake +4 -4
  36. metadata +10 -29
  37. data/lib/async/http/accept_encoding.rb +0 -65
  38. data/lib/async/http/body/buffered.rb +0 -89
  39. data/lib/async/http/body/chunked.rb +0 -76
  40. data/lib/async/http/body/deflate.rb +0 -113
  41. data/lib/async/http/body/file.rb +0 -98
  42. data/lib/async/http/body/fixed.rb +0 -72
  43. data/lib/async/http/body/inflate.rb +0 -59
  44. data/lib/async/http/body/readable.rb +0 -76
  45. data/lib/async/http/body/reader.rb +0 -83
  46. data/lib/async/http/body/remainder.rb +0 -56
  47. data/lib/async/http/body/rewindable.rb +0 -60
  48. data/lib/async/http/body/streamable.rb +0 -83
  49. data/lib/async/http/body/wrapper.rb +0 -65
  50. data/lib/async/http/content_encoding.rb +0 -76
  51. data/lib/async/http/headers.rb +0 -27
  52. data/lib/async/http/middleware.rb +0 -79
  53. data/lib/async/http/middleware/builder.rb +0 -61
  54. data/lib/async/http/request.rb +0 -71
  55. data/lib/async/http/response.rb +0 -90
@@ -1,71 +0,0 @@
1
- # Copyright, 2017, 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_relative 'body/buffered'
22
- require_relative 'body/reader'
23
- require_relative 'middleware'
24
-
25
- module Async
26
- module HTTP
27
- class Request
28
- prepend Body::Reader
29
-
30
- def initialize(scheme = nil, authority = nil, method = nil, path = nil, version = nil, headers = [], body = nil)
31
- @scheme = scheme
32
- @authority = authority
33
- @method = method
34
- @path = path
35
- @version = version
36
- @headers = headers
37
- @body = body
38
- end
39
-
40
- attr_accessor :scheme
41
- attr_accessor :authority
42
- attr_accessor :method
43
- attr_accessor :path
44
- attr_accessor :version
45
- attr_accessor :headers
46
- attr_accessor :body
47
-
48
- def head?
49
- self.method == HEAD
50
- end
51
-
52
- def connect?
53
- self.method == CONNECT
54
- end
55
-
56
- def self.[](method, path, headers, body)
57
- body = Body::Buffered.wrap(body)
58
-
59
- self.new(nil, nil, method, path, nil, headers, body)
60
- end
61
-
62
- def idempotent?
63
- method != POST && (body.nil? || body.empty?)
64
- end
65
-
66
- def to_s
67
- "#{@scheme}://#{@authority}: #{@method} #{@path} #{@version}"
68
- end
69
- end
70
- end
71
- end
@@ -1,90 +0,0 @@
1
- # Copyright, 2017, 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_relative 'body/buffered'
22
- require_relative 'body/reader'
23
-
24
- module Async
25
- module HTTP
26
- class Response
27
- prepend Body::Reader
28
-
29
- def initialize(version = nil, status = 200, reason = nil, headers = [], body = nil)
30
- @version = version
31
- @status = status
32
- @reason = reason
33
- @headers = headers
34
- @body = body
35
- end
36
-
37
- attr_accessor :version
38
- attr_accessor :status
39
- attr_accessor :reason
40
- attr_accessor :headers
41
- attr_accessor :body
42
-
43
- def continue?
44
- status == 100
45
- end
46
-
47
- def success?
48
- status >= 200 && status < 300
49
- end
50
-
51
- def partial?
52
- status == 206
53
- end
54
-
55
- def redirection?
56
- status >= 300 && status < 400
57
- end
58
-
59
- def preserve_method?
60
- status == 307 || status == 308
61
- end
62
-
63
- def failure?
64
- status >= 400 && status < 600
65
- end
66
-
67
- def bad_request?
68
- status == 400
69
- end
70
-
71
- def server_failure?
72
- status == 500
73
- end
74
-
75
- def self.[](status, headers = [], body = nil)
76
- body = Body::Buffered.wrap(body)
77
-
78
- self.new(nil, status, nil, headers, body)
79
- end
80
-
81
- def self.for_exception(exception)
82
- Async::HTTP::Response[500, {'content-type' => 'text/plain'}, ["#{exception.class}: #{exception.message}"]]
83
- end
84
-
85
- def to_s
86
- "#{@status} #{@reason} #{@version}"
87
- end
88
- end
89
- end
90
- end