Creates a 307 "Temporary Redirect" response including a HTTP Warning
        header with code 299 that contains the user message received during
        processing the request.
768272
def create_307_response(self):
        
        request = get_current_request()
        msg_mb = UserMessageMember(self.message)
        coll = request.root['_messages']
        coll.add(msg_mb)
        # Figure out the new location URL.
        qs = self.__get_new_query_string(request.query_string,
                                         self.message.slug)
        resubmit_url = "%s?%s" % (request.path_url, qs)
        headers = [('Warning', '299 %s' % self.message.text),
#                       ('Content-Type', cnt_type),
                   ]
        http_exc = HttpWarningResubmit(location=resubmit_url,
                                       detail=self.message.text,
                                       headers=headers)
        return request.get_response(http_exc)
1047657
public function redirect()
    {
        $this->request->getSession()->set(
            'oauth.temp', $temp = $this->server->getTemporaryCredentials()
        );

        return new RedirectResponse($this->server->getAuthorizationUrl($temp));
    }
458586
def redirect(self, redirect_url=None, message=None, level="info"):
        
        if redirect_url is None:
            redirect_url = self.back_url
        if message is not None:
            self.add_status_message(message, level)
        return self.request.response.redirect(redirect_url)
11126
def redirect(req, _log=pymagic.get_lazy_logger("redirect")):
    
    log = req.environ.get("wsgilog.logger", _log)
    target = req.relative_url(req.urlvars.to)
    log.info("Redirecting '%s' to '%s'" % (req.url, target))
    return exc.HTTPMovedPermanently(location=target)
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
932292
def _raise_redirect_exceptions(response):
    
    if response.status_code not in [301, 302, 307]:
        return None
    new_url = urljoin(response.url, response.headers['location'])
    if 'reddits/search' in new_url:  # Handle non-existent subreddit
        subreddit = new_url.rsplit('=', 1)[1]
        raise InvalidSubreddit('`{0}` is not a valid subreddit'
                               .format(subreddit))
    elif not RE_REDIRECT.search(response.url):
        raise RedirectException(response.url, new_url)
    return new_url
1176432
def redirect(url, status: (env['HTTP_VERSION'] == 'HTTP/1.1') ? 303 : 302, halt: true)
      response['Location'] = absolute(url)
      response.status = status
      self.halt if halt
    end
405298
private void processRedirectResponse(Response response) throws RuntimeException, JSONException, MalformedURLException {
        // a valid redirect response must contain the Location header.
        ResponseImpl responseImpl = (ResponseImpl)response;
        List<String> locationHeaders = responseImpl.getHeader(LOCATION_HEADER_NAME);

        String location = (locationHeaders != null && locationHeaders.size() > 0) ? locationHeaders.get(0) : null;

        if (location == null) {
            throw new RuntimeException("Redirect response does not contain 'Location' header.");
        }

        // the redirect location url should contain "wl_result" value in query parameters.
        URL url = new URL(location);
        String query = url.getQuery();

        if (query.contains(WL_RESULT)) {
            String result = Utils.getParameterValueFromQuery(query, WL_RESULT);
            JSONObject jsonResult = new JSONObject(result);

            // process failures if any
            JSONObject jsonFailures = jsonResult.optJSONObject(AUTH_FAILURE_VALUE_NAME);

            if (jsonFailures != null) {
                processFailures(jsonFailures);
                listener.onFailure(response, null, null);
                return;
            }

            // process successes if any
            JSONObject jsonSuccesses = jsonResult.optJSONObject(AUTH_SUCCESS_VALUE_NAME);

            if (jsonSuccesses != null) {
                processSuccesses(jsonSuccesses);
            }
        }

        // the rest is handles by the caller
        listener.onSuccess(response);
    }
178836
def handle_response(response)
      case response.code.to_i
        when 301,302
          raise "Redirect"
        when 200...400
          response
        when 400
          raise "Bad Request"
        when 401
          raise "Unauthorized Access"
        when 403
          raise "Forbidden Access"
        when 404
          raise "Rescoure not found"
        when 405
          raise "Method not allowed"
        when 409
          raise RequestError.new("Rescource conflict")
        when 422
          raise RequestError.new("Resource invalid")
        when 401...500
          raise "Client error"
        when 500...600
          raise RequestError.new("Server error")
        else
          raise "Unknown response: #{response.code.to_i}"
      end
    end
918458
private boolean processRedirectResponse(final HttpMethod method)
     throws RedirectException {
		//get the location header to find out where to redirect to
		Header locationHeader = method.getResponseHeader("location");
		if (locationHeader == null) {
			// got a redirect response, but no location header
			LOG.error("Received redirect response " + method.getStatusCode()
					+ " but no location header");
			return false;
		}
		String location = locationHeader.getValue();
		if (LOG.isDebugEnabled()) {
			LOG.debug("Redirect requested to location '" + location + "'");
		}
        
		//rfc2616 demands the location value be a complete URI
		//Location       = "Location" ":" absoluteURI
		URI redirectUri = null;
		URI currentUri = null;

		try {
			currentUri = new URI(
				this.conn.getProtocol().getScheme(),
				null,
                this.conn.getHost(), 
                this.conn.getPort(), 
				method.getPath()
			);
			
            String charset = method.getParams().getUriCharset();
            redirectUri = new URI(location, true, charset);
			
            if (redirectUri.isRelativeURI()) {
				if (this.params.isParameterTrue(HttpClientParams.REJECT_RELATIVE_REDIRECT)) {
					LOG.warn("Relative redirect location '" + location + "' not allowed");
					return false;
				} else { 
					//location is incomplete, use current values for defaults
					LOG.debug("Redirect URI is not absolute - parsing as relative");
					redirectUri = new URI(currentUri, redirectUri);
				}
			} else {
                // Reset the default params
                method.getParams().setDefaults(this.params);
            }
            method.setURI(redirectUri);
            hostConfiguration.setHost(redirectUri);
		} catch (URIException ex) {
            throw new InvalidRedirectLocationException(
                    "Invalid redirect location: " + location, location, ex);
		}

        if (this.params.isParameterFalse(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS)) {
            if (this.redirectLocations == null) {
                this.redirectLocations = new HashSet<URI>();
            }
            this.redirectLocations.add(currentUri);
            try {
                if(redirectUri.hasQuery()) {
                    redirectUri.setQuery(null);
                }
            } catch (URIException e) {
                // Should never happen
                return false;
            }

            if (this.redirectLocations.contains(redirectUri)) {
                throw new CircularRedirectException("Circular redirect to '" +
                    redirectUri + "'");
            }
        }

		if (LOG.isDebugEnabled()) {
			LOG.debug("Redirecting from '" + currentUri.getEscapedURI()
				+ "' to '" + redirectUri.getEscapedURI());
		}
        //And finally invalidate the actual authentication scheme
                method.getHostAuthState().invalidate(); 
                method.getProxyAuthState().invalidate(); 
		return true;
	}
672713
static function Redirect($target, $redirectHeader = "", $noExit = false)
    {
        session_write_close();
        if ($redirectHeader)
        {
            header($redirectHeader);
        }
        header("Location: ". $target);
        if (!$noExit)
        {
            exit();
        }
    }
203794
public void redirect(final String location) {
    // set the header AND a meta refresh just in case
    response().headers().set("Location", location);
    sendReply(HttpResponseStatus.OK,
      new StringBuilder(
          "<html></head><meta http-equiv=\"refresh\" content=\"0; url="
           + location + "\"></head></html>")
         .toString().getBytes(this.getCharset())
    );
  }
631641
function httpInternalError(req, res, err) {
    console.error(err);
    res.writeHead(500, { 'Content-Type': 'text/plain' });
    res.write(`Error 500 Internal server error: ${err}`);
    res.end();
}
75588
@Override
    public T handle(final HttpClientResponse response) throws IOException
    {
        if(allowRedirect && response.isRedirected()) {
            LOG.debug("Redirecting based on '%d' response code", response.getStatusCode());
            throw new RedirectedException(response);
        } else {
            // Find the response stream - the error stream may be valid in cases
            // where the input stream is not.
            InputStream is = null;
            try {
                is = response.getResponseBodyAsStream();
            }
            catch (IOException e) {
                LOG.warnDebug(e, "Could not locate response body stream");
                // normal for 401, 403 and 404 responses, for example...
            }

            if (is == null) {
                // Fall back to zero length response.
                is = new NullInputStream(0);
            }

            try {
                final Long contentLength = response.getContentLength();

                if (maxBodyLength > 0) {
                    if (contentLength != null && contentLength > maxBodyLength) {
                        throw new SizeExceededException("Content-Length: " + contentLength);
                    }

                    LOG.debug("Limiting stream length to '%d'", maxBodyLength);
                    is = new SizeLimitingInputStream(is, maxBodyLength);
                }

                final String encoding = StringUtils.trimToEmpty(response.getHeader("Content-Encoding"));

                if (StringUtils.equalsIgnoreCase(encoding, "lz4")) {
                    LOG.debug("Found LZ4 stream");
                    is = new LZ4BlockInputStream(is);
                } else if (StringUtils.equalsIgnoreCase(encoding, "gzip") || StringUtils.equalsIgnoreCase(encoding, "x-gzip")) {
                    LOG.debug("Found GZIP stream");
                    is = new GZIPInputStream(is);
                }
                else if (StringUtils.equalsIgnoreCase(encoding, "deflate")) {
                    LOG.debug("Found deflate stream");
                    final Inflater inflater = new Inflater(true);
                    is = new InflaterInputStream(is, inflater);
                }

                return contentConverter.convert(response, is);
            }
            catch (IOException ioe) {
                return contentConverter.handleError(response, ioe);
            }
        }
    }
715560
function(req, res, response) {

  if (response.status === 302) {
    var location = response.headers.location;
    delete response.headers.location;
    res.set(response.headers);
    res.redirect(location);
  } else {
    res.set(response.headers);
    res.status(response.status).send(response.body);
  }
}
240767
def handle_response(response)
        case response.code.to_i
          when 301,302
            raise(Redirection.new(response))
          when 200...400
            response
          when 400
            raise(BadRequest.new(response))
          when 401
            raise(UnauthorizedAccess.new(response))
          when 403
            raise(ForbiddenAccess.new(response))
          when 404
            raise(ResourceNotFound.new(response))
          when 405
            raise(MethodNotAllowed.new(response))
          when 409
            raise(ResourceConflict.new(response))
          when 422
            raise(ResourceInvalid.new(response))
          when 401...500
            raise(ClientError.new(response))
          when 500...600
            raise(ServerError.new(response))
          else
            raise(ConnectionError.new(response, "Unknown response code: #{response.code}"))
        end
      end
131038
def RedirectDemo(handler, t):
    
    # t.say ("One moment please.")
    t.redirect(SIP_PHONE)
    json = t.RenderJson()
    logging.info ("RedirectDemo json: %s" % json)
    handler.response.out.write(json)