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

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

Introduction

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

Prototype

String CONTENT_TYPE

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

Click Source Link

Document

The HTTP Content-Type header field name.

Usage

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

/**
 * Sends a "normal" response, with all the standard headers. 
 *//*from ww w . ja  v a  2 s  .c  om*/
public static void sendNormalPage(HttpServletResponse response, String body) throws IOException {
    response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate");
    response.setHeader(HttpHeaders.PRAGMA, "no-cache");
    response.setDateHeader(HttpHeaders.EXPIRES, 0);
    response.setHeader(HttpHeaders.CONTENT_TYPE, "text/html; charset=utf-8");
    response.setStatus(200);
    response.getWriter().write(body);
}

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

/**
 * Sends an XSS response of a given type. 
 *//*  w ww .  j  av a  2  s.  c  o m*/
public static void sendXssed(HttpServletResponse response, String body, String contentType) throws IOException {
    response.setHeader(HttpHeaders.X_XSS_PROTECTION, "0");
    response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate");
    response.setHeader(HttpHeaders.PRAGMA, "no-cache");
    response.setDateHeader(HttpHeaders.EXPIRES, 0);
    response.setHeader(HttpHeaders.CONTENT_TYPE, contentType);
    response.setStatus(200);
    response.getWriter().write(body);
}

From source file:ratpack.newrelic.internal.RatpackResponse.java

@Override
public String getContentType() {
    return response.getHeaders().get(HttpHeaders.CONTENT_TYPE);
}

From source file:com.github.achatain.catalog.filter.JsonResponseFilter.java

@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
        throws IOException, ServletException {
    final HttpServletResponse httpResp = (HttpServletResponse) response;
    httpResp.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.JSON_UTF_8.toString());

    chain.doFilter(request, response);//from w w w.j  a  v  a 2  s  . c  om
}

From source file:org.nuxeo.client.internals.spi.auth.BasicAuthInterceptor.java

@Override
public Response intercept(Chain chain) throws IOException {
    Request original = chain.request();
    Request request = chain.request().newBuilder().addHeader(HttpHeaders.AUTHORIZATION, token)
            .addHeader(HttpHeaders.CONTENT_TYPE, com.google.common.net.MediaType.JSON_UTF_8.toString())
            .method(original.method(), original.body()).build();
    return chain.proceed(request);
}

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:com.google.testing.security.firingrange.utils.Responses.java

/**
 * Sends an error to the user with the given {@code status} and body.
 */// w ww .  j  av  a 2 s. com
public static void sendError(HttpServletResponse response, String body, int status) throws IOException {
    Preconditions.checkArgument(status > 300);
    response.setStatus(status);
    response.setHeader(HttpHeaders.CONTENT_TYPE, "text/plain");
    response.getWriter().write(Escaper.escapeHtml(body));
}

From source file:com.cdancy.artifactory.rest.features.ArtifactApi.java

@Named("artifact:deploy")
@Consumes(MediaType.APPLICATION_JSON)/*from   w ww.  j  a va  2 s. c  o m*/
@Path("/{repoKey}/{itemPath}")
@Headers(keys = HttpHeaders.CONTENT_TYPE, values = MediaType.APPLICATION_OCTET_STREAM)
@PUT
Artifact deployArtifact(@PathParam("repoKey") String repoKey, @PathParam("itemPath") String itemPath,
        Payload inputStream,
        @Nullable @BinderParam(BindMatrixPropertiesToPath.class) Map<String, List<String>> properties);

From source file:com.tinspx.util.net.RequestBody.java

public static RequestBody of(ByteSource source, String contentType) {
    return of(source, ImmutableMultimap.of(HttpHeaders.CONTENT_TYPE, contentType), false);
}

From source file:com.tinspx.util.io.charset.DefaultHeaderCharDet.java

@Override
public void onHeader(String name, String value) {
    if (complete) {
        return;/*from  w ww  .j a  v  a2  s . c o m*/
    }
    if (name == null) {
        onError(Errors.create("null header name; values=%s", value));
        return;
    }
    name = name.trim();
    if (name.endsWith(":")) {
        name = name.substring(0, name.length() - 1).trim();
    }
    if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) {
        List<String> charsets = CharsetUtils.parseCharsetString(value);
        if (!setFirstValid(charsets)) {
            onError(Errors.create(this, "invalid charset; value=%s, charsets=%s", value, charsets));
        }
    }
}