07-28-2009 12:05 PM
Hello,
I use this code (snipped) to make an HTTP post and receive compresed data via MDS with the simulator:
URLEncodedPostData encoder = new URLEncodedPostData(null,false); encoder.append("t", data1); encoder.append("s", data2); String postStr = encoder.toString(); String url = "http://www.server.com/index.php;deviceside=false"; this.httpConnection = (HttpConnection)Connector.open(url); this.httpConnection.setRequestMethod("POST"); this.httpConnection.setRequestProperty("Content-Le
ngth", String.valueOf(postStr.toString().getBytes("UTF-8" ).length)); this.httpConnection.setRequestProperty("Content-Ty pe", "application/x-www-form-urlencoded"); this.httpConnection.setRequestProperty("Accept-Enc oding", "gzip"); this.httpConnection.setRequestProperty("x-rim-tran scode-content", "none"); this.httpOutputStream = new OutputStreamWriter(this.httpConnection.openDataOut putStream(), "UTF-8"); this.httpOutputStream.write(postStr); int rc = this.httpConnection.getResponseCode(); if(rc == 200) { String encoding = this.httpConnection.getEncoding(); this.httpInput = this.httpConnection.openInputStream(); if(null != encoding && encoding.equalsIgnoreCase("gzip")) { this.httpInput = new GZIPInputStream(this.httpInput); }
}
}
This works fine with SOME servers. I receive a gzipped stream and properly uncompress it.
The problem is that I cannot serve compressed data to my code from my own server. I run Apache 2 and have tested with both gzip and deflate. Both work fine and serve up compressed pages to browsers. But when this code requests a page, getEncoding() always returns null.
Is there something I have to set on my server to allow it to send compressed data to a BlackBerry? What about on the code side?
I hope I made sense and thanks for the help.
Ty