Browse Source

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 <thomas.wolf@paranor.ch>
stable-5.8
Thomas Wolf 5 years ago committed by Matthias Sohn
parent
commit
04e16afb05
  1. 11
      org.eclipse.jgit/.settings/.api_filters
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
  3. 14
      org.eclipse.jgit/src/org/eclipse/jgit/transport/http/HttpConnection.java

11
org.eclipse.jgit/.settings/.api_filters

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jgit" version="2">
<resource path="src/org/eclipse/jgit/transport/http/HttpConnection.java" type="org.eclipse.jgit.transport.http.HttpConnection">
<filter id="403767336">
<message_arguments>
<message_argument value="org.eclipse.jgit.transport.http.HttpConnection"/>
<message_argument value="HTTP_11_MOVED_PERM"/>
</message_arguments>
</filter>
</resource>
</component>

2
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

14
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 <a href="https://tools.ietf.org/html/rfc7231#section-6.4.7">RFC
* 7231, section 6.4.7: 307 Temporary Redirect</a>
* @since 4.9
*/
int HTTP_11_MOVED_TEMP = 307;
/**
* HTTP 1.1 additional "permanent redirect" status code; value = 308.
*
* @see #HTTP_MOVED_TEMP
* @see <a href="https://tools.ietf.org/html/rfc7538#section-3">RFC 7538,
* section 3: 308 Permanent Redirect</a>
* @since 5.8
*/
int HTTP_11_MOVED_PERM = 308;
/**
* @see HttpURLConnection#HTTP_NOT_FOUND
*/

Loading…
Cancel
Save