Example usage for com.google.common.net HttpHeaders LOCATION

List of usage examples for com.google.common.net HttpHeaders LOCATION

Introduction

In this page you can find the example usage for com.google.common.net HttpHeaders LOCATION.

Prototype

String LOCATION

To view the source code for com.google.common.net HttpHeaders LOCATION.

Click Source Link

Document

The HTTP Location header field name.

Usage

From source file:com.google.zxing.web.AbstractFilter.java

static void redirect(ServletResponse servletResponse, String location) {
    HttpServletResponse response = (HttpServletResponse) servletResponse;
    response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
    response.setHeader(HttpHeaders.LOCATION, location);
}

From source file:org.apache.jclouds.profitbricks.rest.functions.ParseRequestStatusURI.java

@Override
@Nullable//from   w  ww.j  av a 2  s.  c  o  m
public URI apply(HttpResponse input) {
    String location = input.getFirstHeaderOrNull(HttpHeaders.LOCATION);
    return location != null ? URI.create(location) : null;
}

From source file:com.google.zxing.web.LegacyJavadocRedirectServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
    String requestURI = request.getRequestURI();
    Preconditions.checkArgument(requestURI.startsWith(PREFIX));
    String redirectURI = "http://zxing.github.io/zxing/apidocs/" + requestURI.substring(PREFIX.length());
    response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
    response.setHeader(HttpHeaders.LOCATION, redirectURI);
}

From source file:com.google.zxing.web.RedirectFilter.java

private static void redirect(ServletResponse servletResponse, String location) {
    HttpServletResponse response = (HttpServletResponse) servletResponse;
    response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
    response.setHeader(HttpHeaders.LOCATION, location);
}

From source file:org.jclouds.openstack.poppy.v1.functions.ParseServiceURIFromHeaders.java

@Override
public URI apply(HttpResponse response) {
    String locationUri = checkNotNull(response.getFirstHeaderOrNull(HttpHeaders.LOCATION),
            HttpHeaders.LOCATION);/*from w w w  .j a  v  a2 s .  c  o  m*/
    return URI.create(locationUri);
}

From source file:org.killbill.billing.server.filters.ResponseCorsFilter.java

public ResponseCorsFilter() {
    allowedHeaders = Joiner.on(",")
            .join(ImmutableList.<String>of(HttpHeaders.AUTHORIZATION, HttpHeaders.CONTENT_TYPE,
                    HttpHeaders.LOCATION, JaxrsResource.HDR_API_KEY, JaxrsResource.HDR_API_SECRET,
                    JaxrsResource.HDR_COMMENT, JaxrsResource.HDR_CREATED_BY,
                    JaxrsResource.HDR_PAGINATION_CURRENT_OFFSET, JaxrsResource.HDR_PAGINATION_MAX_NB_RECORDS,
                    JaxrsResource.HDR_PAGINATION_NEXT_OFFSET, JaxrsResource.HDR_PAGINATION_NEXT_PAGE_URI,
                    JaxrsResource.HDR_PAGINATION_TOTAL_NB_RECORDS, JaxrsResource.HDR_REASON));
}

From source file:io.gravitee.am.gateway.handler.vertx.handler.login.endpoint.LoginCallbackEndpointHandler.java

private void doRedirect(HttpServerResponse response, String url) {
    response.putHeader(HttpHeaders.LOCATION, url).setStatusCode(302).end();
}

From source file:org.jclouds.s3.handlers.S3RedirectionRetryHandler.java

@Override
public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
    if (response.getFirstHeaderOrNull(HttpHeaders.LOCATION) == null
            && (response.getStatusCode() == 301 || response.getStatusCode() == 307)) {
        command.incrementRedirectCount();
        closeClientButKeepContentStream(response);
        AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response);
        String host = error.getDetails().get("Endpoint");
        if (host != null) {
            if (host.equals(command.getCurrentRequest().getEndpoint().getHost())) {
                // must be an amazon error related to
                // http://developer.amazonwebservices.com/connect/thread.jspa?messageID=72287&#72287
                return backoffHandler.shouldRetryRequest(command, response);
            } else {
                URI newHost = uriBuilder(command.getCurrentRequest().getEndpoint()).host(host).build();
                command.setCurrentRequest(command.getCurrentRequest().toBuilder().endpoint(newHost).build());
            }//w  w  w  .j a  va  2  s  .c  o  m
            return true;
        } else {
            return false;
        }
    } else {
        return super.shouldRetryRequest(command, response);
    }
}

From source file:com.google.testing.security.firingrange.utils.Responses.java

/**
 * Sends a redirect to the user.//from w  ww  .j ava 2 s. c  o  m
 */
public static void sendRedirect(HttpServletResponse response, String location) {
    response.setStatus(302);
    response.setHeader(HttpHeaders.LOCATION, location);
}

From source file:org.wso2.carbon.identity.gateway.local.LocalAuthenticationResponseBuilderFactory.java

@Override
public void createBuilder(Response.ResponseBuilder builder, GatewayResponse gatewayResponse) {
    if (gatewayResponse instanceof LocalAuthenticationResponse) {
        LocalAuthenticationResponse localAuthenticationResponse = (LocalAuthenticationResponse) gatewayResponse;
        builder.status(302);//  w ww .  j  a  va 2 s .  c o  m
        String url = localAuthenticationResponse.getEndpointURL() + "?callback="
                + URLEncoder.encode("https://localhost:9292/gateway") + "&state="
                + localAuthenticationResponse.getRelayState() + "&idplist="
                + localAuthenticationResponse.getIdentityProviderList();
        builder.header(HttpHeaders.LOCATION, url);
    }
}