Returns whether the given HTTP response status code is a redirect code {@code 301, 302, 303,
307}.

@since 1.11
516016
public static boolean isRedirect(int statusCode) {
    switch (statusCode) {
      case HttpStatusCodes.STATUS_CODE_MOVED_PERMANENTLY: // 301
      case HttpStatusCodes.STATUS_CODE_FOUND: // 302
      case HttpStatusCodes.STATUS_CODE_SEE_OTHER: // 303
      case HttpStatusCodes.STATUS_CODE_TEMPORARY_REDIRECT: // 307
        return true;
      default:
        return false;
    }
  }
574359
def redirect(location, code=302, **kw):
    """"""
    if not 300 <= code < 400:
        raise ValueError("Not a 3xx status code: '%s'" % code)
    return response(code=code, location=location, **kw)
856174
protected function _redirect($redirectUrl, $statusCode = 301)
    {
        header('HTTP/1.1 ' . $statusCode);
        header('Location: ' . Router::url($redirectUrl, true));
        exit(0);
    }
93735
private HttpResponse sendRedirectIfPosible() {
		if (this.maxRedirectCount < 1) {
			// 不重定向
			return null;
		}

		// 手动实现重定向
		if (this.httpConnection.getHttpURLConnection().getInstanceFollowRedirects()) {
			int responseCode;
			try {
				responseCode = httpConnection.responseCode();
			} catch (IOException e) {
				throw new HttpException(e);
			}
			if (responseCode != HttpURLConnection.HTTP_OK) {
				if (responseCode == HttpURLConnection.HTTP_MOVED_TEMP || responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_SEE_OTHER) {
					this.url = httpConnection.header(Header.LOCATION);
					if (redirectCount < this.maxRedirectCount) {
						redirectCount++;
						return execute();
					} else {
						StaticLog.warn("URL [{}] redirect count more than two !", this.url);
					}
				}
			}
		}
		return null;
	}
772573
public static boolean isRedirect(String text) {
		boolean result = false;
		String pattern;
		for (int i = 0; i < redirectPatterns.size() && !result; i++) {
			pattern = redirectPatterns.get(i);
			result = text.regionMatches(true, 0, pattern, 0, pattern.length());
		}
		return result;

	}
747185
def is_permanent_redirect(self):
        """"""
        return ('location' in self.headers and self.status_code in (codes.moved_permanently, codes.permanent_redirect))
1168145
private static boolean isHttpSeparator(final char c) {
        if (c < 0x20 || c >= 0x7f) {
            if (c != 0x09) {
                throw UndertowMessages.MESSAGES.invalidControlCharacter(Integer.toString(c));
            }
        }

        return HTTP_SEPARATOR_FLAGS[c];
    }
957878
private boolean shouldOmitPortInHostHeader(HttpUrl url) {
    return (url.scheme().equals("http") && url.port() == 80)
      || (url.scheme().equals("https") && url.port() == 443);
  }
155683
public boolean isHttpRedirect() {
		if (isRevisitDigest() && (getDuplicatePayload() != null)) {
			return getDuplicatePayload().isHttpRedirect();
		}
		String httpCode = getHttpCode();
		return (httpCode.startsWith("3"));
	}
1040278
public static function redirect(string $source_url, string $redirection_url, int $status_code=301)  {
		// create a new route
		$route = new Route();
		// add it to the list of known routes
		self::$_routes[$route->name] = $route
			->setUrl($source_url)
			->setRedirect($redirection_url, $status_code);
		// return the route for finer tuning
		return self::$_routes[$route->name];
	}
290284
private boolean isRedirectNeeded(final HttpMethod method) {
		switch (method.getStatusCode()) {
			case HttpStatus.SC_MOVED_TEMPORARILY:
			case HttpStatus.SC_MOVED_PERMANENTLY:
			case HttpStatus.SC_SEE_OTHER:
			case HttpStatus.SC_TEMPORARY_REDIRECT:
				LOG.debug("Redirect required");
                if (method.getFollowRedirects()) {
                    return true;
                } else {
                    return false;
                }
			default:
				return false;
		} //end of switch
	}
334508
def return! request = nil, result = nil, & block
      if (200..207).include? code
        self
      elsif [301, 302, 307].include? code
        unless [:get, :head].include? args[:method]
          raise Exceptions::EXCEPTIONS_MAP[code].new(self, code)
        else
          follow_redirection(request, result, & block)
        end
      elsif code == 303
        args[:method] = :get
        args.delete :payload
        follow_redirection(request, result, & block)
      elsif Exceptions::EXCEPTIONS_MAP[code]
        raise Exceptions::EXCEPTIONS_MAP[code].new(self, code)
      else
        raise RequestFailed.new(self, code)
      end
    end
1197588
def http_error_307(self, url, fp, errcode, errmsg, headers, data=None):
        """"""
        if data is None:
            return self.http_error_302(url, fp, errcode, errmsg, headers, data)
        else:
            return self.http_error_default(url, fp, errcode, errmsg, headers)
1275575
def redirect(uri, *args)
      if env['HTTP_VERSION'] == 'HTTP/1.1' and env["REQUEST_METHOD"] != 'GET'
        status 303
      else
        status 302
      end

      # According to RFC 2616 section 14.30, "the field value consists of a
      # single absolute URI"
      response['Location'] = uri(uri, settings.absolute_redirects?, settings.prefixed_redirects?)
      halt(*args)
    end
621491
public boolean isHttpSuccess() {
		if (isRevisitDigest() && (getDuplicatePayload() != null)) {
			return getDuplicatePayload().isHttpSuccess();
		}
		String httpCode = getHttpCode();
		return (httpCode.startsWith("2"));
	}
326304
private static void checkHttpResponseCodeValid(URLConnection connection) throws RepositoryHttpException, IOException {
        // if HTTP URL not File URL
        if (connection instanceof HttpURLConnection) {
            HttpURLConnection conn = (HttpURLConnection) connection;
            conn.setRequestMethod("GET");
            int respCode = conn.getResponseCode();
            if (respCode < 200 || respCode >= 300) {
                throw new RepositoryHttpException("HTTP connection returned error code " + respCode, respCode, null);
            }
        }
    }
934433
function redirect($url, $type = 303) {
		if ($type === 303) {
			$this->http_response_code(303);
		}
		else if ($type == 301) {
			$this->http_response_code(301);
		}
		else if ($type == 307) {
			$this->http_response_code(307);
		}

		// redirect to...
		$this->header("Location: $url");
	}