qeweney 0.11 → 0.13

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: 256f14b402547865d5b7ce2357ef5ac79cd4f1f8e30129544450c7b8a60e39bb
4
- data.tar.gz: 94ecbd44f44c1e858873315780ae0661237692a20396bf0a06b96497ea93f76a
3
+ metadata.gz: 742be1b1238ea117928a544134e57702776b707caf0cccdf68b74225ff3990d7
4
+ data.tar.gz: 357beb13e5f99b3f776de0a9e30447a034a647af208c1d69adedc118cabe8be1
5
5
  SHA512:
6
- metadata.gz: 794a72410e59205ae66325aea81ee3d8a3b3e2bdaa7053118922e9a855f6d0e474d7d1e741787fe4b753a9c626e2672d9de4b95af14dc80c3f4a62175f72f0e5
7
- data.tar.gz: 1775acaaa03ab16287f18dd18deb8d4720febcd2d13d1e502afbe8525a244921bb2b2946dee15da949f1aae9ed803275c2faf7b4675e4f6f6542554769ca0b94
6
+ metadata.gz: 2b0249f07ce24a2acb3d9d20a9a43927de50217b9b27d23b911819c50ad6ca6312c395c966ebd57fda8db69908de392667ed3294ced76d4143b1ecbc37820cef
7
+ data.tar.gz: c80e535de1921e6b655a019c74a1a35fc808a9a7088ef368b84a485b42582d37d03ac9eb53250fd73277fe077cdd6c28ae6a4f60b814931fd6150f22ab929a42
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.13 2021-08-02
2
+
3
+ - Restore `Request#complete?` method
4
+ - Add buffered_only argument to `Request#next_chunk`
5
+
6
+ ## 0.12 2021-07-30
7
+
8
+ - Remove `Request#consume` method
9
+ - Remove `Request#complete?` and associated methods
10
+
1
11
  ## 0.11 2021-07-26
2
12
 
3
13
  - Fix rack env (digital-fabric/tipi#11)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qeweney (0.11)
4
+ qeweney (0.13)
5
5
  escape_utils (~> 1.2.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # Qeweney
1
+ # Qeweney - add water, makes its own sauce!
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/qeweney.svg)](http://rubygems.org/gems/qeweney)
4
+ [![Modulation Test](https://github.com/digital-fabric/qeweney/workflows/Tests/badge.svg)](https://github.com/digital-fabric/qeweney/actions?query=workflow%3ATests)
5
+ [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/digital-fabric/qeweney/blob/master/LICENSE)
2
6
 
3
7
  ## Cross-library HTTP request / response API for servers
4
8
 
data/lib/qeweney/rack.rb CHANGED
@@ -67,12 +67,33 @@ module Qeweney
67
67
  end
68
68
  end
69
69
 
70
+ # TODO: integrate in env
71
+ # Implements a rack input stream:
72
+ # https://www.rubydoc.info/github/rack/rack/master/file/SPEC#label-The+Input+Stream
73
+ class InputStream
74
+ def initialize(request)
75
+ @request = request
76
+ end
77
+
78
+ def gets; end
79
+
80
+ def read(length = nil, outbuf = nil); end
81
+
82
+ def each(&block)
83
+ @request.each_chunk(&block)
84
+ end
85
+
86
+ def rewind; end
87
+ end
88
+
70
89
  def self.rack_env_from_request(request)
71
90
  Hash.new do |h, k|
72
91
  h[k] = rack_env_value_from_request(request, k)
73
92
  end
74
93
  end
75
94
 
95
+ # TODO: improve conformance to rack spec
96
+ # TODO: set values like port, scheme etc from actual connection
76
97
  RACK_ENV = {
77
98
  'SCRIPT_NAME' => '',
78
99
  'rack.version' => [1, 3],
@@ -27,14 +27,16 @@ module Qeweney
27
27
  @buffered_body_chunks << chunk
28
28
  end
29
29
 
30
- def next_chunk
30
+ def next_chunk(buffered_only = false)
31
31
  if @buffered_body_chunks
32
32
  chunk = @buffered_body_chunks.shift
33
33
  @buffered_body_chunks = nil if @buffered_body_chunks.empty?
34
34
  return chunk
35
+ elsif buffered_only
36
+ return nil
35
37
  end
36
38
 
37
- @message_complete ? nil : @adapter.get_body_chunk(self)
39
+ @adapter.get_body_chunk(self, buffered_only)
38
40
  end
39
41
 
40
42
  def each_chunk
@@ -44,37 +46,19 @@ module Qeweney
44
46
  end
45
47
  @buffered_body_chunks = nil
46
48
  end
47
- while !@message_complete && (chunk = @adapter.get_body_chunk(self))
49
+ while (chunk = @adapter.get_body_chunk(self))
48
50
  yield chunk
49
51
  end
50
52
  end
51
53
 
52
- def complete!(keep_alive = nil)
53
- @message_complete = true
54
- @keep_alive = keep_alive
55
- end
56
-
57
- def complete?
58
- @message_complete
59
- end
60
-
61
- def consume
62
- @adapter.consume_request(self)
63
- end
64
-
65
- def keep_alive?
66
- @keep_alive
67
- end
68
-
69
54
  def read
70
- buf = @buffered_body_chunks ? @buffered_body_chunks.join : nil
71
- while (chunk = @adapter.get_body_chunk(self))
72
- (buf ||= +'') << chunk
73
- end
74
- @buffered_body_chunks = nil
75
- buf
55
+ @adapter.get_body(self)
76
56
  end
77
57
  alias_method :body, :read
58
+
59
+ def complete?
60
+ @adapter.complete?(self)
61
+ end
78
62
 
79
63
  def respond(body, headers = {})
80
64
  @adapter.respond(self, body, headers)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Qeweney
4
- VERSION = '0.11'
4
+ VERSION = '0.13'
5
5
  end
@@ -179,7 +179,7 @@ class ServeRackTest < MiniTest::Test
179
179
  })
180
180
 
181
181
  assert_equal [
182
- [:respond, r, 'get /foo/bar', {':status' => 404, 'Foo' => 'Bar' }]
182
+ [:respond, r, 'GET /foo/bar', {':status' => 404, 'Foo' => 'Bar' }]
183
183
  ], r.response_calls
184
184
  end
185
185
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qeweney
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.11'
4
+ version: '0.13'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-26 00:00:00.000000000 Z
11
+ date: 2021-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils