jgit/org.eclipse.jgit.junit.http
Thomas Wolf e17bfc96f2 Add support to follow HTTP redirects
git-core follows HTTP redirects so JGit should also provide this.

Implement config setting http.followRedirects with possible values
"false" (= never), "true" (= always), and "initial" (only on GET, but
not on POST).[1]

We must do our own redirect handling and cannot rely on the support
that the underlying real connection may offer. At least the JDK's
HttpURLConnection has two features that get in the way:

* it does not allow cross-protocol redirects and thus fails on
  http->https redirects (for instance, on Github).
* it translates a redirect after a POST to a GET unless the system
  property "http.strictPostRedirect" is set to true. We don't want
  to manipulate that system setting nor require it.

Additionally, git has its own rules about what redirects it accepts;[2]
for instance, it does not allow a redirect that adds query arguments.

We handle response codes 301, 302, 303, and 307 as per RFC 2616.[3]
On POST we do not handle 303, and we follow redirects only if
http.followRedirects == true.

Redirects are followed only a certain number of times. There are two
ways to control that limit:

* by default, the limit is given by the http.maxRedirects system
  property that is also used by the JDK. If the system property is
  not set, the default is 5. (This is much lower than the JDK default
  of 20, but I don't see the value of following so many redirects.)
* this can be overwritten by a http.maxRedirects git config setting.

The JGit http.* git config settings are currently all global; JGit has
no support yet for URI-specific settings "http.<pattern>.name". Adding
support for that is well beyond the scope of this change.

Like git-core, we log every redirect attempt (LOG.info) so that users
may know about the redirection having occurred.

Extends the test framework to configure an AppServer with HTTPS support
so that we can test cloning via HTTPS and redirections involving HTTPS.

[1] https://git-scm.com/docs/git-config
[2] 6628eb41db
[3] https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

CQ: 13987
Bug: 465167
Change-Id: I86518cb76842f7d326b51f8715e3bbf8ada89859
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2017-08-17 22:16:44 +02:00
..
.settings Enable and fix warnings about redundant specification of type arguments 2017-02-20 22:47:23 +01:00
META-INF Add support to follow HTTP redirects 2017-08-17 22:16:44 +02:00
src/org/eclipse/jgit/junit/http Add support to follow HTTP redirects 2017-08-17 22:16:44 +02:00
.classpath Change JGit minimum execution environment to JavaSE-1.8 2016-09-20 11:32:36 +02:00
.gitignore Introduce http test bundle 2010-12-08 16:20:28 +01:00
.project Enforce the use of Java5 API:s only (with a few exceptions) 2011-12-16 01:01:36 +01:00
BUILD Bazel: Restrict src globs to Java source files 2017-04-13 14:14:55 +09:00
build.properties Fix line endings 2013-05-03 16:19:07 +02:00
plugin.properties Fix plugin provider names to conform with release train requirement 2013-04-08 23:05:36 +02:00
pom.xml Prepare 4.9.0-SNAPSHOT builds 2017-05-30 13:42:07 +02:00