Redirect this request with 3xx status
967464
async def redirect(self, path, status = 302):
        
        location = urljoin(urlunsplit((b'https' if self.https else b'http',
                                                                     self.host,
                                                                     quote_from_bytes(self.path).encode('ascii'),
                                                                     '',
                                                                     ''
                                                                     )), path)
        self.start_response(status, [(b'Location', location)])
        await self.write(b'<a href="' + self.escape(location, True) + b'">' + self.escape(location) + b'</a>')
        await self.flush(True)
741120
def run_request(name='default', **kwargs):
    '''
    
    '''
    req = check_request()
    if name not in req:
        return {}
    n_req = req[name]
    if 'mods' not in n_req or 'kwargs' not in n_req:
        return {}
    req[name]['kwargs'].update(kwargs)
    if 'test' in n_req['kwargs']:
        n_req['kwargs'].pop('test')
    if req:
        ret = apply_(n_req['mods'], **n_req['kwargs'])
        try:
            os.remove(os.path.join(__opts__['cachedir'], 'req_state.p'))
        except (IOError, OSError):
            pass
        return ret
    return {}
60788
def _action(self, res):
        """"""
        try:
            j = res.json()
        except:
            res.raise_for_status()
            j = {}

        if 'Retry-After' in res.headers:
            raise HTTPError('403 Forbidden: API rate-limit has been reached until {}.'
                            'See http://freshdesk.com/api#ratelimit'.format(res.headers['Retry-After']))

        if 'require_login' in j:
            raise HTTPError('403 Forbidden: API key is incorrect for this domain')

        if 'error' in j:
            raise HTTPError('{}: {}'.format(j.get('description'),
                                            j.get('errors')))

        # Catch any other errors
        try:
            res.raise_for_status()
        except Exception as e:
            raise HTTPError("{}: {}".format(e, j))

        return j
304713
def set_redirect(self, url, status=HttpStatusCodes.HTTP_303):
        
        self.set_status(status)
        self.set_content('')
        self.set_header(HttpResponseHeaders.LOCATION, url)
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)
494381
function redirectToNext(req, res) {
  var redirectTo = req.session.next || '';
  req.session.next = null; // Null it so that we do not use it again.
  res.redirect(redirectTo);
}
526159
def raise_for_status(self, allow_redirects=True):
        """"""

        if self.status_code == 304:
            return
        elif self.error:
            if self.traceback:
                six.reraise(Exception, Exception(self.error), Traceback.from_string(self.traceback).as_traceback())
            http_error = HTTPError(self.error)
        elif (self.status_code >= 300) and (self.status_code < 400) and not allow_redirects:
            http_error = HTTPError('%s Redirection' % (self.status_code))
        elif (self.status_code >= 400) and (self.status_code < 500):
            http_error = HTTPError('%s Client Error' % (self.status_code))
        elif (self.status_code >= 500) and (self.status_code < 600):
            http_error = HTTPError('%s Server Error' % (self.status_code))
        else:
            return

        http_error.response = self
        raise http_error
361986
def http_get(uri, retries_left = 10)
      raise RedirectError, 'Too many redirects' if retries_left.zero?

      case (response = Net::HTTP.get_response(URI(uri)))
      when Net::HTTPClientError
        nil
      when Net::HTTPServerError
        raise Net::HTTPServerException.new(response.message, response)
      when Net::HTTPFound, Net::HTTPPermanentRedirect
        http_get(response['location'], retries_left - 1)
      else
        StringIO.new(response.body)
      end
    end
800216
function(cb) {
          var opts = {
            url: uri + 'user/stream',
            method: 'GET',
            qs: qs,
            json: true
          };
          request(opts,function(e,r,b) {
            if (e) cb(e)
            else {
              if (r.statusCode==200) cb(null, b)
              else {
                cb({statusCode:r.statusCode,error:b.error})
              }
            }
          });
        }
888923
function tempRedirect(req, res) {
        var params = {
            Bucket: S3_BUCKET,
            Key: checkTrailingSlash(getFileKeyDir(req)) + req.params[0]
        };
        var s3 = getS3();
        s3.getSignedUrl('getObject', params, function(err, url) {
            res.redirect(url);
        });
    }
910187
def raise_on_self_redirect(self, params, cdx, status_code, location_url):
        
        if cdx.get('is_live'):
            return

        if not status_code.startswith('3') or status_code == '304':
            return

        request_url = params['url'].lower()
        if not location_url:
            return


        location_url = location_url.lower()
        if location_url.startswith('/'):
            host = urlsplit(cdx['url']).netloc
            location_url = host + location_url

        location_url = location_url.split('://', 1)[-1].rstrip('/')
        request_url = request_url.split('://', 1)[-1].rstrip('/')

        self_redir = False

        if request_url == location_url:
            self_redir = True
        elif params.get('sr-urlkey'):
            # if new location canonicalized matches old key, also self-redirect
            if canonicalize(location_url) == params.get('sr-urlkey'):
                self_redir = True

        if self_redir:
            msg = 'Self Redirect {0} -> {1}'
            msg = msg.format(request_url, location_url)
            params['sr-urlkey'] = cdx['urlkey']
            raise LiveResourceException(msg)
660718
function redirect() {
    l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + repo + '/?' +
      (l.pathname ? 'p=' + l.pathname.replace(/&/g, '~and~').replace(repo, '') : '') +
      (l.search ? '&q=' + l.search.slice(1).replace(/&/g, '~and~') : '') +
      (l.hash))
  }
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
898151
def http_error_302(self, url, fp, errcode, errmsg, headers, data=None):
        """"""
        self.tries += 1
        if self.maxtries and self.tries >= self.maxtries:
            if hasattr(self, "http_error_500"):
                meth = self.http_error_500
            else:
                meth = self.http_error_default
            self.tries = 0
            return meth(url, fp, 500,
                        "Internal Server Error: Redirect Recursion", headers)
        result = self.redirect_internal(url, fp, errcode, errmsg, headers,
                                        data)
        self.tries = 0
        return result
30824
def system_whoami(input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/system/whoami', input_params, always_retry=always_retry, **kwargs)
1062106
def redirect_to(uri)
      raise StateError, "no Location header in redirect" unless uri

      verb = @request.verb
      code = @response.status.code

      if UNSAFE_VERBS.include?(verb) && STRICT_SENSITIVE_CODES.include?(code)
        raise StateError, "can't follow #{@response.status} redirect" if @strict
        verb = :get
      end

      verb = :get if !SEE_OTHER_ALLOWED_VERBS.include?(verb) && 303 == code

      @request.redirect(uri, verb)
    end
320870
function(req, params) {
    if(!params) {
      params = URL.parse(req.url, true).query;
    }
    var cconfig = this.config.client;
    var next = params.next || cconfig.default_redirection_url;
    var url = cconfig.base_url + next;
    return url;
  }