jubilee 1.1.0.rc1 → 1.1.0.rc2
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38c7ff14a0556dd319caf62874e40fc69a1380c2
|
4
|
+
data.tar.gz: 3022b1786dda6ac2a2cef500e5f128996225159c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccf4e457c07dd123ed41aed249cb3a8c632b789dfeb5c9a937fc52274dc8b857cba2e89e05dee742e0937cf312ef019dba25d6ba931675dc98c8baaf7c8aa82d
|
7
|
+
data.tar.gz: 2dffccc0cd663b3254123e7b3b0f81c89acea0e1ffbd0c9a9af2335218f768ab4688c1835a22d480319f747d4900285d4b44050ef5c5581c55e9750e7860344e
|
data/README.md
CHANGED
@@ -15,7 +15,6 @@ import org.jruby.util.ByteList;
|
|
15
15
|
import org.jruby.util.StringSupport;
|
16
16
|
import org.vertx.java.core.http.HttpServerRequest;
|
17
17
|
|
18
|
-
import java.util.Arrays;
|
19
18
|
import java.util.concurrent.atomic.AtomicBoolean;
|
20
19
|
|
21
20
|
/**
|
@@ -26,7 +25,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|
26
25
|
*/
|
27
26
|
public class RubyIORackInput extends RubyObject implements RackInput {
|
28
27
|
private Encoding BINARY = ASCIIEncoding.INSTANCE;
|
29
|
-
private HttpServerRequest request;
|
30
28
|
private int len;
|
31
29
|
private boolean chunked;
|
32
30
|
private ByteBuf buf;
|
@@ -52,7 +50,6 @@ public class RubyIORackInput extends RubyObject implements RackInput {
|
|
52
50
|
|
53
51
|
public RubyIORackInput(Ruby runtime, RubyClass rubyClass, HttpServerRequest request, ByteBuf buf, AtomicBoolean eof) {
|
54
52
|
this(runtime, rubyClass);
|
55
|
-
this.request = request;
|
56
53
|
String hdr = request.headers().get(Const.Vertx.CONTENT_LENGTH);
|
57
54
|
this.chunked = hdr == null;
|
58
55
|
this.len = this.chunked ? 0 : Integer.parseInt(hdr);
|
@@ -71,16 +68,19 @@ public class RubyIORackInput extends RubyObject implements RackInput {
|
|
71
68
|
@Override
|
72
69
|
@JRubyMethod
|
73
70
|
public IRubyObject gets(ThreadContext context) {
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
Ruby runtime = context.runtime;
|
72
|
+
RubyString line = RubyString.newEmptyString(context.runtime, BINARY);
|
73
|
+
|
74
|
+
if (isEOF()) return runtime.getNil();
|
75
|
+
|
77
76
|
int lineEnd = -1;
|
78
|
-
while (lineEnd == -1 && !
|
77
|
+
while (lineEnd == -1 && !eof.get()) {
|
79
78
|
lineEnd = buf.indexOf(buf.readerIndex(), buf.writerIndex(), Const.EOL);
|
79
|
+
}
|
80
80
|
|
81
81
|
// No line break found, read all
|
82
82
|
if (lineEnd == -1)
|
83
|
-
return readAll(line);
|
83
|
+
return readAll(runtime, line);
|
84
84
|
|
85
85
|
int readLength = lineEnd - buf.readerIndex();
|
86
86
|
byte[] dst = new byte[readLength + 1];
|
@@ -105,22 +105,23 @@ public class RubyIORackInput extends RubyObject implements RackInput {
|
|
105
105
|
@Override
|
106
106
|
@JRubyMethod(optional = 2)
|
107
107
|
public IRubyObject read(ThreadContext context, IRubyObject[] args) {
|
108
|
-
|
108
|
+
Ruby runtime = context.runtime;
|
109
|
+
RubyString dst = RubyString.newStringNoCopy(context.runtime, new ByteList(), BINARY, StringSupport.CR_VALID);
|
109
110
|
if (isEOF())
|
110
|
-
return
|
111
|
+
return runtime.getNil();
|
111
112
|
int length;
|
112
113
|
switch (args.length) {
|
113
114
|
case 0:
|
114
|
-
return readAll(dst);
|
115
|
+
return readAll(runtime, dst);
|
115
116
|
case 1:
|
116
|
-
length =
|
117
|
+
length = RubyNumeric.num2int(args[0]);
|
117
118
|
break;
|
118
119
|
default:
|
119
|
-
length =
|
120
|
+
length = RubyNumeric.num2int(args[0]);
|
120
121
|
dst = (RubyString) args[1];
|
121
122
|
}
|
122
123
|
if (length < 0)
|
123
|
-
|
124
|
+
runtime.newArgumentError("Negative length " + length + " given");
|
124
125
|
byte[] buffer = new byte[length];
|
125
126
|
int toRead = length;
|
126
127
|
while (toRead > 0 && !isEOF()) {
|
@@ -146,7 +147,7 @@ public class RubyIORackInput extends RubyObject implements RackInput {
|
|
146
147
|
while (!(str = gets(context)).isNil()) {
|
147
148
|
block.yield(context, str);
|
148
149
|
}
|
149
|
-
return
|
150
|
+
return context.runtime.getNil();
|
150
151
|
}
|
151
152
|
|
152
153
|
/**
|
@@ -162,7 +163,7 @@ public class RubyIORackInput extends RubyObject implements RackInput {
|
|
162
163
|
@JRubyMethod
|
163
164
|
public IRubyObject rewind(ThreadContext context) {
|
164
165
|
buf.readerIndex(0);
|
165
|
-
return
|
166
|
+
return context.runtime.getNil();
|
166
167
|
}
|
167
168
|
|
168
169
|
/**
|
@@ -172,7 +173,7 @@ public class RubyIORackInput extends RubyObject implements RackInput {
|
|
172
173
|
@JRubyMethod
|
173
174
|
public IRubyObject close(ThreadContext context) {
|
174
175
|
buf.clear();
|
175
|
-
return
|
176
|
+
return context.runtime.getNil();
|
176
177
|
}
|
177
178
|
|
178
179
|
private int readableBytes() {
|
@@ -188,14 +189,13 @@ public class RubyIORackInput extends RubyObject implements RackInput {
|
|
188
189
|
return buf.readableBytes() == 0 && eof.get();
|
189
190
|
}
|
190
191
|
|
191
|
-
private IRubyObject readAll(RubyString dst) {
|
192
|
-
buf.readerIndex(0);
|
192
|
+
private IRubyObject readAll(Ruby runtime, RubyString dst) {
|
193
193
|
while(!eof.get())
|
194
194
|
; // wait until all data received
|
195
195
|
int length = this.chunked ? buf.readableBytes() : Math.min(this.len, buf.readableBytes());
|
196
196
|
byte[] data = new byte[length];
|
197
197
|
buf.readBytes(data);
|
198
198
|
dst.cat(data);
|
199
|
-
return dst.isEmpty() ?
|
199
|
+
return dst.isEmpty() ? runtime.getNil() : dst;
|
200
200
|
}
|
201
201
|
}
|
data/lib/jubilee/jubilee.jar
CHANGED
Binary file
|
data/lib/jubilee/version.rb
CHANGED