If you need a stream why don't you just use HttpEntity?
// Get hold of the response entity
HttpEntity entity = response.getEntity();
// If the response does not enclose an entity, there is no need
// to worry about connection release
if (entity != null) {
InputStream instream = entity.getContent();
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(instream));
// do something useful with the response
System.out.println(reader.readLine());
} catch (IOException ex) {
...
}
On Sep 4, 11:10 am, Marco Schmitz <[email protected]>
wrote:
> thank you droidin,
>
> unfortunately I didnt need the httpclient but the stream.
>
> well, I found a solution :)
>
> btw: this is sdk 1.1 r1 code:
>
> greetings,
> marco
>
> ------------------------------------------------------------------------
> import java.io.BufferedReader;
> import java.io.InputStreamReader;
> import java.net.URL;
> import java.security.SecureRandom;
> import java.security.cert.X509Certificate;
>
> import javax.net.ssl.HostnameVerifier;
> import javax.net.ssl.HttpsURLConnection;
> import javax.net.ssl.SSLContext;
> import javax.net.ssl.SSLSession;
> import javax.net.ssl.TrustManager;
> import javax.net.ssl.X509TrustManager;
>
> import lgpl.haustein.Base64Encoder;
>
> import org.apache.log4j.Appender;
> import org.apache.log4j.AppenderSkeleton;
> import org.apache.log4j.Layout;
> import org.apache.log4j.Level;
> import org.apache.log4j.Logger;
> import org.apache.log4j.PatternLayout;
> import org.apache.log4j.spi.LoggingEvent;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.util.Log;
>
> /**
> * Hyper
> */
> public class Hyper extends Activity {
>
> private static Logger logger = Logger.getLogger(Hyper.class);
>
> private static final String HTTP = "http://www.gmx.de";
> private static final String HTTPS = "https://www.verisign.com/";
>
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
> logger.debug("START");
>
> try {
> SSLContext sc = SSLContext.getInstance("TLS");
> scinit(null, new TrustManager[] { new
> MyTrustManager() }, new
> SecureRandom());
>
> HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
> HttpsURLConnection.setDefaultHostnameVerifier(new
> MyHostnameVerifier());
> HttpsURLConnection con = (HttpsURLConnection) new
> URL(HTTPS).openConnection();
> con.setDoOutput(true);
> con.setDoInput(true);
> con.connect();
>
> BufferedReader br = new BufferedReader(new
> InputStreamReader(con.getInputStream()));
> StringBuffer sb = new StringBuffer();
> String line;
> while ((line = br.readLine()) != null)
> sb.append(line);
>
> logger.debug("InputStream: " + sb.toString());
>
> logger.debug("END");
> } catch (Exception e) {
> logger.error(e);
> }
> }
>
> /**
> * MyHostnameVerifier
> */
> private class MyHostnameVerifier implements HostnameVerifier {
>
> @Override
> public boolean verify(String hostname, SSLSession session) {
> return true;
> }
> }
>
> /**
> * MyTrustManager
> */
> private class MyTrustManager implements X509TrustManager {
>
> @Override
> public void checkClientTrusted(X509Certificate[] chain,
> String authType) {
> }
>
> @Override
> public void checkServerTrusted(X509Certificate[] chain,
> String authType) {
> }
>
> @Override
> public X509Certificate[] getAcceptedIssuers() {
> return null;
> }
> }
>
> }
>
> ------------------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---