I am implementing ResponseCache for HttpUrlConnection in android. Everything seems to work. I call
ResponseCache.setDefault(new ResCache()); And the methods in my ResCache class are being used as expected. The only problem I am having is that the Map with request Parameters is empty. If I try this very same code outside of an android environment, I will be able to see the request Header parameter, but inside an activity and all that stuff is not working. Here is the code for the Activity. package com.httptest; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.CacheRequest; import java.net.CacheResponse; import java.net.HttpURLConnection; import java.net.ResponseCache; import java.net.URI; import java.net.URL; import java.net.URLConnection; import java.util.List; import java.util.Map; import android.app.Activity; import android.os.Bundle; public class HttpTest extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ResponseCache.setDefault(new ResCache()); HttpURLConnection urlConnection = null; try { URL url = new URL("http://169.254.198.146//patch/500.php"); urlConnection = (HttpURLConnection) url .openConnection(); urlConnection.setUseCaches(true); urlConnection.setRequestProperty("MY_PROPERTY", "MY_VALUE"); InputStream in = new BufferedInputStream( urlConnection.getInputStream()); String aux = readStream(in); }catch(Exception e){ e.printStackTrace(); }finally { urlConnection.disconnect(); } } public static String readStream(InputStream in) throws IOException { StringBuilder sb = new StringBuilder(); BufferedReader r = new BufferedReader(new InputStreamReader(in), 1000); for (String line = r.readLine(); line != null; line = r.readLine()) { sb.append(line); } in.close(); return sb.toString(); } public class ResCache extends ResponseCache{ @Override public CacheResponse get(URI arg0, String arg1, Map<String, List<String>> arg2) throws IOException { System.out.println(arg2); return null; } @Override public CacheRequest put(URI uri, URLConnection connection) throws IOException { return null; } } } In the method ResCache.get(URI, String, Map), the map is always empty. I would like to see the parameters I added to the request. By the way the parameters all well set in the request, as I can read them in the server when performing the request. Again, this works outside of an android environment. Any help with this? Thank you! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en