uringmachine 0.28.1 → 0.28.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9fb662e62914ca38e254df5ee924b61155b510d3e862efa2f2e0997b00e7b3fd
4
- data.tar.gz: 6ea55d8b64df3873677d1243342d5d6163812068392498f1f080351d0fc9d3e2
3
+ metadata.gz: 21a7c3c4503c06967ae77b6b3c8da3fb0f19eae3373efccb018ff111dc6d2aa8
4
+ data.tar.gz: 5376adb14245278692e634fdb6843080239a7a806b13032706b91036a9483c1a
5
5
  SHA512:
6
- metadata.gz: 3ca70d442ad7b7379dccb7e1e6df6acac913f2b5ae9ac9a2ca87b8ab5ecac5efd00454888921faa7960321f91493ad10dd337ab043fc3b4771fdb6bc17dead0b
7
- data.tar.gz: 6e4102474725dc14bf91690edcaf0e53d3eb9c7796b8edd72e2ec89629b7fc2c821e2a8c1e1abfaf52f0a27d9dd8153e6b750ed3f525436162bd93db7bf5aece
6
+ metadata.gz: 0b00614b471f51e8c3e31c77b2844284c371a4c0a73b30c0016969421ee20777ce2ca5ee215201a1a31aec189f7f703f39a0884c262c3ffc5c36ccbbae73a6f1
7
+ data.tar.gz: 26efdd3e98c013e9edd0962cc0fcab3bd9454485743fabc05a1d181200ad256aeb649618193048451850b39623f48cd69e9563f21defb8a178c5dcc300f24eb5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.28.2 2026-02-20
2
+
3
+ - Fix `Stream#get_string`
4
+
1
5
  # 0.28.1 2026-02-20
2
6
 
3
7
  - Add `Stream#machine`, `Stream#fd`
data/ext/um/um_stream.c CHANGED
@@ -56,8 +56,8 @@ static inline void str_copy_bytes(VALUE dest, const char *src, ssize_t len) {
56
56
  }
57
57
 
58
58
  VALUE stream_get_line(struct um_stream *stream, VALUE buf, ssize_t maxlen) {
59
- char *start = RSTRING_PTR(stream->buffer) + stream->pos;
60
59
  while (true) {
60
+ char *start = RSTRING_PTR(stream->buffer) + stream->pos;
61
61
  ssize_t pending_len = stream->len - stream->pos;
62
62
  ssize_t search_len = pending_len;
63
63
  ssize_t absmax_len = labs(maxlen);
@@ -76,32 +76,31 @@ VALUE stream_get_line(struct um_stream *stream, VALUE buf, ssize_t maxlen) {
76
76
  return buf;
77
77
  }
78
78
  else if (should_limit_len && pending_len > search_len)
79
- // maxlen
79
+ // hit maxlen
80
80
  return Qnil;
81
81
 
82
82
  if (!stream_read_more(stream))
83
83
  return Qnil;
84
- else
85
- // update start ptr (it might have changed after reading)
86
- start = RSTRING_PTR(stream->buffer) + stream->pos;
87
84
  }
88
85
  }
89
86
 
90
87
  VALUE stream_get_string(struct um_stream *stream, VALUE buf, ssize_t len) {
91
88
  size_t abslen = labs(len);
92
- while (stream->len - stream->pos < abslen)
89
+ while (stream->len - stream->pos < abslen) {
93
90
  if (!stream_read_more(stream)) {
94
- if (len > 0) return Qnil;
91
+ if (len > 0)
92
+ return Qnil;
95
93
 
96
94
  abslen = stream->len - stream->pos;
97
95
  }
96
+ }
98
97
 
99
98
  char *start = RSTRING_PTR(stream->buffer) + stream->pos;
100
99
  stream->pos += abslen;
101
100
 
102
101
  if (NIL_P(buf)) return rb_utf8_str_new(start, abslen);
103
102
 
104
- str_copy_bytes(buf, start, len);
103
+ str_copy_bytes(buf, start, abslen);
105
104
  return buf;
106
105
  }
107
106
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UringMachine
4
- VERSION = '0.28.1'
4
+ VERSION = '0.28.2'
5
5
  end
data/test/test_stream.rb CHANGED
@@ -234,3 +234,20 @@ class StreamRespTest < StreamBaseTest
234
234
  s.resp_encode_cmd(+'', :set, 'foobar', :nx, :xx)
235
235
  end
236
236
  end
237
+
238
+ class StreamHTTPTest < StreamBaseTest
239
+ def test_stream_http_etc
240
+ machine.write(@wfd, "GET / HTTP/1.1\r\n\r\nblahblah")
241
+ machine.close(@wfd)
242
+
243
+ l = @stream.get_line(nil, 0)
244
+ assert_equal "GET / HTTP/1.1", l
245
+
246
+ l = @stream.get_line(nil, 0)
247
+ assert_equal '', l
248
+
249
+ l = @stream.get_string(nil, -50)
250
+ assert_equal 'blahblah', l
251
+ end
252
+ end
253
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uringmachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.1
4
+ version: 0.28.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner