From 04e16afb05912f3a163d8cda3560a5b2f1ea997f Mon Sep 17 00:00:00 2001 From: Thomas Wolf Date: Mon, 9 Mar 2020 23:41:37 +0100 Subject: [PATCH] TransportHttp: support HTTP response 308 Permanent Redirect RFC 7538[1] added HTTP response code 308, signifying a permanent redirect that, contrary to the older 301, does not allow changing the request method from POST to GET. [1] https://tools.ietf.org/html/rfc7538 Bug: 560936 Change-Id: Ib65f3a3ed75db51d74d1fe81d4abe6fe92b0ca12 Signed-off-by: Thomas Wolf --- org.eclipse.jgit/.settings/.api_filters | 11 +++++++++++ .../org/eclipse/jgit/transport/TransportHttp.java | 2 ++ .../jgit/transport/http/HttpConnection.java | 14 +++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 org.eclipse.jgit/.settings/.api_filters diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters new file mode 100644 index 000000000..c8b7bf799 --- /dev/null +++ b/org.eclipse.jgit/.settings/.api_filters @@ -0,0 +1,11 @@ + + + + + + + + + + + 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 356f88d91..c3c1f2a40 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java @@ -549,6 +549,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, case HttpConnection.HTTP_MOVED_PERM: case HttpConnection.HTTP_MOVED_TEMP: case HttpConnection.HTTP_SEE_OTHER: + case HttpConnection.HTTP_11_MOVED_PERM: case HttpConnection.HTTP_11_MOVED_TEMP: // SEE_OTHER should actually never be sent by a git server, // and in general should occur only on POST requests. But it @@ -1412,6 +1413,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, case HttpConnection.HTTP_MOVED_PERM: case HttpConnection.HTTP_MOVED_TEMP: + case HttpConnection.HTTP_11_MOVED_PERM: case HttpConnection.HTTP_11_MOVED_TEMP: // SEE_OTHER after a POST doesn't make sense for a git // server, so we don't handle it here and thus we'll diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/HttpConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/HttpConnection.java index a5f2bc605..c4d086d4b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/HttpConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/HttpConnection.java @@ -59,13 +59,25 @@ public interface HttpConnection { int HTTP_SEE_OTHER = java.net.HttpURLConnection.HTTP_SEE_OTHER; /** - * HTTP 1.1 additional MOVED_TEMP status code; value = 307. + * HTTP 1.1 additional "temporary redirect" status code; value = 307. * * @see #HTTP_MOVED_TEMP + * @see RFC + * 7231, section 6.4.7: 307 Temporary Redirect * @since 4.9 */ int HTTP_11_MOVED_TEMP = 307; + /** + * HTTP 1.1 additional "permanent redirect" status code; value = 308. + * + * @see #HTTP_MOVED_TEMP + * @see RFC 7538, + * section 3: 308 Permanent Redirect + * @since 5.8 + */ + int HTTP_11_MOVED_PERM = 308; + /** * @see HttpURLConnection#HTTP_NOT_FOUND */