Skip to content

Commit

Permalink
Fix for feature request olap4j#23. Adds support for GZIP compression …
Browse files Browse the repository at this point in the history
…in the HTTP proxy.
  • Loading branch information
lucboudreau committed Feb 10, 2014
1 parent e33d7d8 commit d01460d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/org/olap4j/driver/xmla/proxy/XmlaOlap4jHttpProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.*;
import java.net.*;
import java.util.concurrent.Future;
import java.util.zip.GZIPInputStream;

/**
* Extends the AbstractCachedProxy and serves as
Expand Down Expand Up @@ -87,6 +88,11 @@ public byte[] getResponse(XmlaOlap4jServerInfos serverInfos, String request)
getEncodingCharsetName()
.concat(";q=1"));

// Tell the server that we support gzip encoding
urlConnection.setRequestProperty(
"Accept-Encoding",
"gzip");

// Some servers expect a SOAPAction header.
// TODO There is bound to be a better way to do this.
if (request.contains(DISCOVER)) {
Expand Down Expand Up @@ -128,6 +134,14 @@ public byte[] getResponse(XmlaOlap4jServerInfos serverInfos, String request)

// Get the response, again assuming default encoding.
InputStream is = urlConnection.getInputStream();

// Detect that the server used gzip encoding
String contentEncoding =
urlConnection.getHeaderField("Content-Encoding");
if("gzip".equals(contentEncoding)) {
is = new GZIPInputStream(is);
}

final ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int count;
Expand Down

0 comments on commit d01460d

Please sign in to comment.