public InputStream getInputStream ( ) { try { int responseCode = this . urlConnection . getResponseCode ( ) ; try { // HACK: manually follow redirects, for the login to work // HTTPUrlConnection auto redirect doesn't respect the provided headers if ( responseCode == 302 ) { HttpClient redirectClient = new HttpClient ( proxyHost , proxyPort , urlConnection . getHeaderField ( "Location" ) , headers , urlConnection . getRequestMethod ( ) , callback , authHeader ) ; redirectClient . getInputStream ( ) . close ( ) ; } } catch ( Throwable e ) { System . out . println ( "Following redirect failed" ) ; } setCookieHeader = this . urlConnection . getHeaderField ( "Set-Cookie" ) ; InputStream in = responseCode != HttpURLConnection . HTTP_OK ? this . urlConnection . getErrorStream ( ) : this . urlConnection . getInputStream ( ) ; return in ; } catch ( Exception e ) { return null ; } }
returns the inputstream from URLConnection