0

I wrote a code to parse and manipulate some data in a 3rd party website using jsoup. The website reponses HTTP 401 if user is not logged in and shows login form. Since JSoup throws exceptions in these cases(Http response is not 2xx or 3xx) i used ignoreHttpErrors(true) in my connection.

The odd part is when i test the android application that uses that code it works fine on android ICS, Kitkat and lollipop but when i test it in android 2.3.7 on emulator the following code throws IOException with "Received authentication challenge is null" message.

       Jsoup.connect(address)
            .method(Connection.Method.GET)
            .ignoreHttpErrors(true)
            .timeout(30 * 1000)
            .execute()

and the as i mentioned ignoreHttpErrors doesn't help. What is different between these versions?! (I am trying to run it on android 3.x too) Is this something about JSoup or android? Is there a workaround to have compatibility with android 2.x?

Mohammad Jafar Mashhadi
  • 4,102
  • 3
  • 29
  • 49
  • Duplicate of http://stackoverflow.com/questions/12931791/java-io-ioexception-received-authentication-challenge-is-null-in-ics-4-0-3 and http://stackoverflow.com/questions/1357372/ioexception-received-authentication-challenge-is-null-apache-harmony-android. Maybe the versions of android that work as expected are treating the malformed response differently. – Alkis Kalogeris Nov 29 '14 at 18:10
  • @alkis I'm using jsoup, not directly using HttpConnection class – Mohammad Jafar Mashhadi Nov 29 '14 at 18:15
  • I believe you meant `HttpURLConnection` class. Jsoup uses `HttpURLConnection` underneath, and as it seems, when it receives this error, since it's not an Http error, it bubbles it so you can catch it. What I'm trying to say, is that there is no difference. What you can do to have it work, is to catch it, and treat it as you like. – Alkis Kalogeris Nov 29 '14 at 18:23

0 Answers0