Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix for feature request #23. Adds support for GZIP compression in the…

… HTTP proxy.
  • Loading branch information...
commit d01460d9408a6a8f7267d54172e5e276bbaf1924 1 parent e33d7d8
@lucboudreau lucboudreau authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/org/olap4j/driver/xmla/proxy/XmlaOlap4jHttpProxy.java
View
14 src/org/olap4j/driver/xmla/proxy/XmlaOlap4jHttpProxy.java
@@ -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
@@ -87,6 +88,11 @@ public XmlaOlap4jHttpProxy(
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)) {
@@ -128,6 +134,14 @@ public XmlaOlap4jHttpProxy(
// 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;
Please sign in to comment.
Something went wrong with that request. Please try again.