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

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

Introduction

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

Prototype

String IF_MATCH

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

Click Source Link

Document

The HTTP If-Match header field name.

Usage

From source file:org.jclouds.openstack.swift.v1.options.CopyOptions.java

public CopyOptions ifMatch(String ifMatch) {
    this.headers.put(HttpHeaders.IF_MATCH, ifMatch);
    return this;
}

From source file:org.ldp4j.server.controller.PreconditionRequiredException.java

public PreconditionRequiredException(OperationContext context) {
    super(context, null, Diagnosis.create().statusCode(MoreHttp.PRECONDITION_REQUIRED_STATUS_CODE)
            .diagnostic("No %s header specified.", HttpHeaders.IF_MATCH).mandatory(true));
}

From source file:org.ldp4j.server.controller.providers.PreconditionRequiredExceptionMapper.java

@Override
public Response toResponse(PreconditionRequiredException throwable) {
    String message = String.format("No %s header specified.", HttpHeaders.IF_MATCH);
    ResponseBuilder builder = Response.status(PRECONDITION_REQUIRED).language(Locale.ENGLISH)
            .type(MediaType.TEXT_PLAIN).entity(message);
    EndpointControllerUtils.populateProtocolEndorsedHeaders(builder, throwable.getResource());
    EndpointControllerUtils.populateProtocolSpecificHeaders(builder, throwable.getResource());
    return builder.build();
}

From source file:org.sonatype.nexus.repository.http.HttpConditions.java

@Nullable
private static Predicate<Response> ifMatch(final Request request) {
    final String match = request.getHeaders().get(HttpHeaders.IF_MATCH);
    if (match != null && !"*".equals(match)) {
        return new Predicate<Response>() {
            @Override/*from  w w w  .  j a  v a2s . c o  m*/
            public boolean apply(final Response response) {
                final String etag = response.getHeaders().get(HttpHeaders.ETAG);
                if (etag != null) {
                    return match.contains(etag);
                }
                return true;
            }

            @Override
            public String toString() {
                return HttpConditions.class.getSimpleName() + ".ifMatch(" + match + ")";
            }
        };
    }
    return null;
}