// SubURLRedirect responses redirection wtih given location and status.
// It prepends setting.AppSubURL to the location string.
486247
func (c *Context) SubURLRedirect(location string, status ...int) {
	c.Redirect(setting.AppSubURL+location, status...)
}
426473
func (c *xContext) Redirect(url string, codes ...int) error {
	code := http.StatusFound
	if len(codes) > 0 {
		code = codes[0]
	}
	if code < http.StatusMultipleChoices || code > http.StatusTemporaryRedirect {
		return ErrInvalidRedirectCode
	}
	err := c.preResponse()
	if err != nil {
		return err
	}
	format := c.Format()
	if format != `html` && c.auto {
		if render, ok := c.echo.formatRenderers[format]; ok && render != nil {
			if c.dataEngine.GetData() == nil {
				c.Set(`Location`, url)
				c.dataEngine.SetData(c.Stored(), c.dataEngine.GetCode().Int())
			} else {
				c.dataEngine.SetURL(url)
			}
			return render(c, c.dataEngine.GetData())
		}
	}
	c.response.Redirect(url, code)
	return nil
}
788453
func (c *DefaultClient) SubscribeAppUplink(appID string, handler UplinkHandler) Token {
	return c.SubscribeDeviceUplink(appID, "", handler)
}
909650
func (h *HTTPBin) Redirect(w http.ResponseWriter, r *http.Request) {
	params := r.URL.Query()
	relative := strings.ToLower(params.Get("absolute")) != "true"
	doRedirect(w, r, relative)
}
1072171
func RouteOriginalURL(r *http.Request) {
	// RawPath is only set if the url had special characters or was canonized.
	if len(r.URL.RawPath) > 0 {
		plog.WithFields(log.Fields{
			"Path":    r.URL.Path,
			"RawPath": r.URL.RawPath,
		}).Debug("handler: rewriting url")
		r.URL.Opaque = r.URL.RawPath
	}
}
68325
func (c *Context) Redirect(url string, code int) error {
	if code < http.StatusMultipleChoices || code > http.StatusTemporaryRedirect {
		return errors.New("invalid redirect code")
	}
	http.Redirect(c.response, c.request, url, code)
	return nil
}
787783
func (p *Processor) RedirectURI(originURL string) string {
	p.RLock()
	defer p.RUnlock()

	return p.userTokenHandler.IssueRedirect(originURL)
}
1052533
func (user *User) OauthRedirectURL() string {
	providerID := user.ctx.OAuthProvider().internalID()
	if providerID == user.ctx.ServiceName {
		return fmt.Sprintf("%s/auth/%s", Config.BaseURL, user.ctx.ServiceName)
	}

	return fmt.Sprintf("%s/auth/%s/%s", Config.BaseURL, user.ctx.ServiceName, providerID)
}
292505
func crrevRedirect(ctx context.Context, client *http.Client, query string) (redirect string, err error) {
	// API Explorer for this API:
	// https://cr-rev.appspot.com/_ah/api/explorer#p/crrev/v1/crrev.redirect.get
	u := "https://cr-rev.appspot.com/_ah/api/crrev/v1/redirect/" + url.PathEscape(query)
	res, err := ctxhttp.Get(ctx, client, u)
	if err != nil {
		return "", err
	}
	defer res.Body.Close()

	if res.StatusCode != http.StatusOK {
		return "", fmt.Errorf("%s", res.Status)
	}

	var body struct {
		RedirectURL string `json:"redirect_url"`
	}
	switch err := json.NewDecoder(res.Body).Decode(&body); {
	case err != nil:
		return "", fmt.Errorf("decoding crrev.com response: %s", err)
	case body.RedirectURL == "":
		return "", fmt.Errorf("crrev.com redirected to nothing")
	default:
		return body.RedirectURL, nil
	}
}
662362
func RedirectHandler(w http.ResponseWriter, r *http.Request) {
	n := mux.Vars(r)["n"]
	i, _ := strconv.Atoi(n) // shouldn't fail due to route pattern

	var loc string
	if i <= 1 {
		loc = "/get"
	} else {
		loc = fmt.Sprintf("/redirect/%d", i-1)
	}
	w.Header().Set("Location", loc)
	w.WriteHeader(http.StatusFound)
}
293409
func (c *DefaultClient) SubscribeAppDownlink(appID string, handler DownlinkHandler) Token {
	return c.SubscribeDeviceDownlink(appID, "", handler)
}
413170
func (req *AuthnRequest) Redirect(relayState string) *url.URL {
	w := &bytes.Buffer{}
	w1 := base64.NewEncoder(base64.StdEncoding, w)
	w2, _ := flate.NewWriter(w1, 9)
	doc := etree.NewDocument()
	doc.SetRoot(req.Element())
	if _, err := doc.WriteTo(w2); err != nil {
		panic(err)
	}
	w2.Close()
	w1.Close()

	rv, _ := url.Parse(req.Destination)

	query := rv.Query()
	query.Set("SAMLRequest", string(w.Bytes()))
	if relayState != "" {
		query.Set("RelayState", relayState)
	}
	rv.RawQuery = query.Encode()

	return rv
}
364374
func (ctx *Context) Redirect(status int, url_ string) {
	ctx.ResponseWriter.Header().Set("Location", url_)
	ctx.ResponseWriter.WriteHeader(status)
	ctx.ResponseWriter.Write([]byte("Redirecting to: " + url_))
}
1260918
func (s *HeadObjectOutput) SetWebsiteRedirectLocation(v string) *HeadObjectOutput {
	s.WebsiteRedirectLocation = &v
	return s
}
1080806
func RedirectToHandler(w http.ResponseWriter, r *http.Request) {
	u := mux.Vars(r)["url"]
	w.Header().Set("Location", u)
	w.WriteHeader(http.StatusFound)
}
989874
func httpRedirect(path string) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		http.Redirect(w, r, path, http.StatusFound)
	})
}
54516
func TemporaryRedirect(w http.ResponseWriter, response interface{}) {
	Respond(w, http.StatusTemporaryRedirect, response)
}