Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

For JRUBY-5778: net http and gzip decompression in 1.9

* Add GzipWriter and GzipReader#initialize that accepts options hash (ignored for now).
* Full impl in 1.6.5?
  • Loading branch information...
commit cc2c489eeb88125e3210f0183e0a94b26d9c2b21 1 parent b637df5
Charles Oliver Nutter headius authored
Showing with 35 additions and 5 deletions.
  1. +35 −5 src/org/jruby/RubyZlib.java
40 src/org/jruby/RubyZlib.java
View
@@ -46,6 +46,7 @@
import java.util.zip.DeflaterOutputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
+import org.jcodings.Encoding;
import org.joda.time.DateTime;
@@ -71,6 +72,8 @@
import org.jruby.util.IOOutputStream;
import org.jruby.util.io.Stream;
+import static org.jruby.CompatVersion.*;
+
@JRubyModule(name="Zlib")
public class RubyZlib {
// version
@@ -1429,8 +1432,8 @@ private long bytesToUInt(byte[] bytes, int pos) {
}
@JRubyMethod(visibility = PRIVATE)
- public IRubyObject initialize(IRubyObject arg, Block unusedBlock) {
- realIo = arg;
+ public IRubyObject initialize(IRubyObject stream) {
+ realIo = stream;
line = 0;
position = 0;
io = new HeaderReadableGZIPInputStream(new CountingIOInputStream(realIo));
@@ -1438,6 +1441,17 @@ public IRubyObject initialize(IRubyObject arg, Block unusedBlock) {
return this;
}
+ @JRubyMethod(visibility = PRIVATE, compat = RUBY1_9)
+ public IRubyObject initialize19(IRubyObject stream) {
+ return initialize(stream);
+ }
+
+ @JRubyMethod(visibility = PRIVATE, compat = RUBY1_9)
+ public IRubyObject initialize19(IRubyObject stream, IRubyObject options) {
+ initialize(stream);
+ return this;
+ }
+
@JRubyMethod
public IRubyObject rewind() {
Ruby rt = getRuntime();
@@ -1445,7 +1459,7 @@ public IRubyObject rewind() {
realIo.callMethod(rt.getCurrentContext(), "seek",
new IRubyObject[]{rt.newFixnum(-io.pos()), rt.newFixnum(Stream.SEEK_CUR)});
// ... and then reinitialize
- initialize(realIo, Block.NULL_BLOCK);
+ initialize(realIo);
return getRuntime().getNil();
}
@@ -1878,8 +1892,13 @@ private void writeTrailer() throws IOException {
private HeaderModifyableGZIPOutputStream io;
@JRubyMethod(required = 1, rest = true, visibility = PRIVATE)
- public IRubyObject initialize(IRubyObject[] args, Block unusedBlock) {
- realIo = (RubyObject) args[0];
+ public IRubyObject initialize(IRubyObject[] args) {
+ return initialize(args[0]);
+ }
+
+ @JRubyMethod(visibility = PRIVATE)
+ public IRubyObject initialize(IRubyObject arg) {
+ realIo = (RubyObject) arg;
try {
io = new HeaderModifyableGZIPOutputStream(realIo);
return this;
@@ -1888,6 +1907,17 @@ public IRubyObject initialize(IRubyObject[] args, Block unusedBlock) {
}
}
+ @JRubyMethod(visibility = PRIVATE, compat = RUBY1_9)
+ public IRubyObject initialize19(IRubyObject stream) {
+ return initialize(stream);
+ }
+
+ @JRubyMethod(visibility = PRIVATE, compat = RUBY1_9)
+ public IRubyObject initialize19(IRubyObject stream, IRubyObject options) {
+ initialize(stream);
+ return this;
+ }
+
@Override
@JRubyMethod(name = "close")
public IRubyObject close() {
Please sign in to comment.
Something went wrong with that request. Please try again.