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

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

Introduction

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

Prototype

String X_REQUESTED_WITH

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

Click Source Link

Document

The HTTP X-Requested-With header field name.

Usage

From source file:org.graylog2.shared.rest.NotAuthorizedResponseFilter.java

@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
        throws IOException {
    if (responseContext.getStatusInfo().equals(Response.Status.UNAUTHORIZED)) {
        final String requestedWith = requestContext.getHeaderString(HttpHeaders.X_REQUESTED_WITH);
        if ("XMLHttpRequest".equalsIgnoreCase(requestedWith)) {
            responseContext.getHeaders().remove(HttpHeaders.WWW_AUTHENTICATE);

        }/*w w w .  j  a  v  a  2 s.c  om*/
    }
}