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 +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/um/um_stream.c +7 -8
- data/lib/uringmachine/version.rb +1 -1
- data/test/test_stream.rb +17 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 21a7c3c4503c06967ae77b6b3c8da3fb0f19eae3373efccb018ff111dc6d2aa8
|
|
4
|
+
data.tar.gz: 5376adb14245278692e634fdb6843080239a7a806b13032706b91036a9483c1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b00614b471f51e8c3e31c77b2844284c371a4c0a73b30c0016969421ee20777ce2ca5ee215201a1a31aec189f7f703f39a0884c262c3ffc5c36ccbbae73a6f1
|
|
7
|
+
data.tar.gz: 26efdd3e98c013e9edd0962cc0fcab3bd9454485743fabc05a1d181200ad256aeb649618193048451850b39623f48cd69e9563f21defb8a178c5dcc300f24eb5
|
data/CHANGELOG.md
CHANGED
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)
|
|
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,
|
|
103
|
+
str_copy_bytes(buf, start, abslen);
|
|
105
104
|
return buf;
|
|
106
105
|
}
|
|
107
106
|
|
data/lib/uringmachine/version.rb
CHANGED
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
|
+
|