diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java index 19b3ab6a7..f4471bf83 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java @@ -52,6 +52,7 @@ import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_ENCODING; import static org.eclipse.jgit.util.HttpSupport.HDR_CONTENT_TYPE; import static org.eclipse.jgit.util.HttpSupport.HDR_PRAGMA; import static org.eclipse.jgit.util.HttpSupport.HDR_USER_AGENT; +import static org.eclipse.jgit.util.HttpSupport.HDR_WWW_AUTHENTICATE; import static org.eclipse.jgit.util.HttpSupport.METHOD_GET; import static org.eclipse.jgit.util.HttpSupport.METHOD_POST; @@ -474,6 +475,13 @@ public class TransportHttp extends HttpTransport implements WalkTransport, final int status = HttpSupport.response(conn); switch (status) { case HttpConnection.HTTP_OK: + // Check if HttpConnection did some authentication in the + // background (e.g Kerberos/SPNEGO). + // That may not work for streaming requests and jgit + // explicit authentication would be required + if (authMethod == HttpAuthMethod.NONE + && conn.getHeaderField(HDR_WWW_AUTHENTICATE) != null) + authMethod = HttpAuthMethod.scanResponse(conn); return conn; case HttpConnection.HTTP_NOT_FOUND: