servicetalk-http-utils/src/main/java/io/servicetalk/http/utils/RedirectSingle.java
/**
         * Returns a value of {@link HttpHeaderNames#LOCATION} header or {@code null} if we should not redirect.
         */
Returns a value of  HttpHeaderNames#LOCATION header or  null if we should not redirect.
Returns a value of HttpHeaderNames#LOCATION header or null if we should not redirect .
@Nullable
        private String redirectLocation(final int redirectCount, final HttpRequestMethod requestMethod,
                                        final HttpResponseMetaData responseMetaData) {
            final int statusCode = responseMetaData.status().code();
            if (statusCode < 300 || statusCode > 308 || (statusCode >= 304 && statusCode <= 306)) {
                return null;
            }
            final RedirectConfig config = redirectSingle.config;
            if (redirectCount >= config.maxRedirects()) {
                LOGGER.debug("Maximum number of redirects ({}) reached for original request: {}",
                        config.maxRedirects(), redirectSingle.originalRequest);
                return null;
            }
            if (!config.allowedMethods().contains(requestMethod)) {
                LOGGER.debug("Configuration does not allow redirect of method: {}", requestMethod);
                return null;
            }
            final CharSequence locationHeader = responseMetaData.headers().get(LOCATION);
            if (locationHeader == null || locationHeader.length() == 0) {
                LOGGER.debug("No location header in redirect response: {}", responseMetaData);
                return null;
            }
            return locationHeader.toString();
        }
@ Nullable private String redirectLocation ( final int redirectCount , final HttpRequestMethod requestMethod , final HttpResponseMetaData responseMetaData ) { final int statusCode = responseMetaData . status ( ) . code ( ) ; if ( statusCode < 300 || statusCode > 308 || ( statusCode >= 304 && statusCode <= 306 ) ) { return null ; } final RedirectConfig config = redirectSingle . config ; if ( redirectCount >= config . maxRedirects ( ) ) { LOGGER . debug ( "Maximum number of redirects ({}) reached for original request: {}" , config . maxRedirects ( ) , redirectSingle . originalRequest ) ; return null ; } if ( ! config . allowedMethods ( ) . contains ( requestMethod ) ) { LOGGER . debug ( "Configuration does not allow redirect of method: {}" , requestMethod ) ; return null ; } final CharSequence locationHeader = responseMetaData . headers ( ) . get ( LOCATION ) ; if ( locationHeader == null || locationHeader . length ( ) == 0 ) { LOGGER . debug ( "No location header in redirect response: {}" , responseMetaData ) ; return null ; } return locationHeader . toString ( ) ; }
Returns a value of {@link HttpHeaderNames#LOCATION} header or {@code null} if we should not redirect.
Returns a value of { @link HttpHeaderNames#LOCATION } header or { @code null } if we should not redirect .
// We start without support for status codes outside of the standard range // https://tools.ietf.org/html/rfc7232#section-4.1 // The 304 (Not Modified) status code indicates that the cache value is still fresh and can be used. // https://tools.ietf.org/html/rfc7231#section-6.4.5 // The 305 (Use Proxy) status code has been deprecated due to security concerns regarding in-band // configuration of a proxy. // https://tools.ietf.org/html/rfc7231#section-6.4.6 // The 306 (Unused) status code is no longer used, and the code is reserved.