@ -73,6 +73,7 @@ import java.util.Arrays;
import java.util.Collection ;
import java.util.Collection ;
import java.util.Collections ;
import java.util.Collections ;
import java.util.EnumSet ;
import java.util.EnumSet ;
import java.util.HashSet ;
import java.util.LinkedHashSet ;
import java.util.LinkedHashSet ;
import java.util.Map ;
import java.util.Map ;
import java.util.Set ;
import java.util.Set ;
@ -95,6 +96,7 @@ import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Ref ;
import org.eclipse.jgit.lib.Ref ;
import org.eclipse.jgit.lib.Repository ;
import org.eclipse.jgit.lib.Repository ;
import org.eclipse.jgit.lib.SymbolicRef ;
import org.eclipse.jgit.lib.SymbolicRef ;
import org.eclipse.jgit.transport.HttpAuthMethod.Type ;
import org.eclipse.jgit.transport.http.HttpConnection ;
import org.eclipse.jgit.transport.http.HttpConnection ;
import org.eclipse.jgit.util.HttpSupport ;
import org.eclipse.jgit.util.HttpSupport ;
import org.eclipse.jgit.util.IO ;
import org.eclipse.jgit.util.IO ;
@ -448,9 +450,11 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
throw new NotSupportedException ( MessageFormat . format ( JGitText . get ( ) . invalidURL , uri ) , e ) ;
throw new NotSupportedException ( MessageFormat . format ( JGitText . get ( ) . invalidURL , uri ) , e ) ;
}
}
try {
int authAttempts = 1 ;
int authAttempts = 1 ;
Collection < Type > ignoreTypes = null ;
for ( ; ; ) {
for ( ; ; ) {
try {
final HttpConnection conn = httpOpen ( u ) ;
final HttpConnection conn = httpOpen ( u ) ;
if ( useSmartHttp ) {
if ( useSmartHttp ) {
String exp = "application/x-" + service + "-advertisement" ; //$NON-NLS-1$ //$NON-NLS-2$
String exp = "application/x-" + service + "-advertisement" ; //$NON-NLS-1$ //$NON-NLS-2$
@ -467,7 +471,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
// explicit authentication would be required
// explicit authentication would be required
if ( authMethod . getType ( ) = = HttpAuthMethod . Type . NONE
if ( authMethod . getType ( ) = = HttpAuthMethod . Type . NONE
& & conn . getHeaderField ( HDR_WWW_AUTHENTICATE ) ! = null )
& & conn . getHeaderField ( HDR_WWW_AUTHENTICATE ) ! = null )
authMethod = HttpAuthMethod . scanResponse ( conn ) ;
authMethod = HttpAuthMethod . scanResponse ( conn , ignoreTypes ) ;
return conn ;
return conn ;
case HttpConnection . HTTP_NOT_FOUND :
case HttpConnection . HTTP_NOT_FOUND :
@ -475,7 +479,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
MessageFormat . format ( JGitText . get ( ) . uriNotFound , u ) ) ;
MessageFormat . format ( JGitText . get ( ) . uriNotFound , u ) ) ;
case HttpConnection . HTTP_UNAUTHORIZED :
case HttpConnection . HTTP_UNAUTHORIZED :
authMethod = HttpAuthMethod . scanResponse ( conn ) ;
authMethod = HttpAuthMethod . scanResponse ( conn , ignoreTypes ) ;
if ( authMethod . getType ( ) = = HttpAuthMethod . Type . NONE )
if ( authMethod . getType ( ) = = HttpAuthMethod . Type . NONE )
throw new TransportException ( uri , MessageFormat . format (
throw new TransportException ( uri , MessageFormat . format (
JGitText . get ( ) . authenticationNotSupported , uri ) ) ;
JGitText . get ( ) . authenticationNotSupported , uri ) ) ;
@ -501,15 +505,29 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
String err = status + " " + conn . getResponseMessage ( ) ; //$NON-NLS-1$
String err = status + " " + conn . getResponseMessage ( ) ; //$NON-NLS-1$
throw new TransportException ( uri , err ) ;
throw new TransportException ( uri , err ) ;
}
}
}
} catch ( NotSupportedException e ) {
} catch ( NotSupportedException e ) {
throw e ;
throw e ;
} catch ( TransportException e ) {
} catch ( TransportException e ) {
throw e ;
throw e ;
} catch ( IOException e ) {
} catch ( IOException e ) {
if ( authMethod . getType ( ) ! = HttpAuthMethod . Type . NONE ) {
if ( ignoreTypes = = null ) {
ignoreTypes = new HashSet < Type > ( ) ;
}
ignoreTypes . add ( authMethod . getType ( ) ) ;
// reset auth method & attempts for next authentication type
authMethod = HttpAuthMethod . Type . NONE . method ( null ) ;
authAttempts = 1 ;
continue ;
}
throw new TransportException ( uri , MessageFormat . format ( JGitText . get ( ) . cannotOpenService , service ) , e ) ;
throw new TransportException ( uri , MessageFormat . format ( JGitText . get ( ) . cannotOpenService , service ) , e ) ;
}
}
}
}
}
final HttpConnection httpOpen ( URL u ) throws IOException {
final HttpConnection httpOpen ( URL u ) throws IOException {
return httpOpen ( METHOD_GET , u ) ;
return httpOpen ( METHOD_GET , u ) ;