Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

.getInputStream() returns java.util.zip.GZIPInputStream...

$
0
0
Hello everyone,

I'm currently stuck.

I'm currently developing an app for the 4.0.3 Android SDK, but I figured this is more of a Java problem then Android.

I'm trying to establish an HTTP connection using the HttpURLConnection class. Once I have successfully connected (.getResponseCode returns '200'), I call the '.getInputStream()' method of HttpURLConnection, expecting it to return the XML data of the URL. However, InputStream 'is' only contains the following after the method call:

java.util.zip.GZIPInputStream@41c62c08



This sucks.

Here's my code:

url = new URL("http://www.cinema.de/kino/neu-im-kino/rss.xml");
. . .

	private class HttpRequestTask extends AsyncTask<URL, Void, InputStream>
	{
		@Override
		protected InputStream doInBackground (URL... urls)
		{
			InputStream is = null;
			HttpURLConnection conn = null; 
			String str = null;
			
			// Attempt to establish connection  & retrieve data as InputStream
			try
			{
				conn = (HttpURLConnection) urls[0].openConnection();
				conn.setRequestMethod("GET");
				conn.setAllowUserInteraction(false);
				conn.setInstanceFollowRedirects(true);
				conn.setReadTimeout(15000);
				conn.setConnectTimeout(15000);
				conn.setDoInput(true);
				conn.connect();
				
				int http_response = conn.getResponseCode();
				Log.e(getClass().getSimpleName(), "HTTP Response: " + http_response);
				
				is = conn.getInputStream();
			}
. . .



I haven't been able to find a solution to this problem, other than a few people saying the header of the GZIP compression file is being sent; I don't know how to use this information to help me. If I use the HttpClient class, I get a similar problem (useless response). I've also used other URLs, to no avail.

Any help is greatly appreciated! This problem is driving me up the wall...

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>