Hi

I have been working with the HttpsUrlConnection class and have found
an interesting issue, it seems to fail on every other connection.  The
first request connects to the server successfully but the second one
always fails.  Any ideas on what i may be doing wrong.  Here is my
code.

Many Thanks

HttpsURLConnection httpConnection = null;
                InputStream is = null;

                try {
                        httpConnection = (HttpsURLConnection) new 
URL(url).openConnection
();
                        httpConnection.setRequestProperty( "User-Agent", 
"Mozilla/5.0
(Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/
2.0.0.1" );

                        httpConnection.setHostnameVerifier(new 
HostnameVerifier() {
                                public boolean verify(String hostname, 
SSLSession session) {
                                        return true;
                                }
                        });

                        httpConnection.setDoOutput(true);
                        httpConnection.setDoInput(true);
                        httpConnection.setUseCaches(false);
                        httpConnection.setRequestProperty("Authorization", 
"Basic " +
Base64Encoder.encode(username, password));

                        is = httpConnection.getInputStream();
                        return parseXmlData(is, type);
                }
                catch (MalformedURLException e) {
                        e.printStackTrace();
                }
                catch (IOException e) {
                        e.printStackTrace();
                }
                finally {
                        if(is != null) {
                                try {

                                        is.close();
                                } catch (IOException e) {
                                        e.printStackTrace();
                                }

                                is = null;
                        }

                        if(httpConnection != null) {
                                httpConnection.disconnect();
                                httpConnection = null;
                        }
                }

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to