Esempio n. 1
0
  private void ifMatch(DavRequest request, DavResponse response, DavResource resource)
      throws DavException, IOException {
    EntityTag[] requestEtags = request.getIfMatch();
    if (requestEtags.length == 0) return;

    EntityTag resourceEtag = etag(resource);
    if (resourceEtag == null) return;

    if (EntityTag.matchesAny(resourceEtag, requestEtags)) return;

    if (resourceEtag != null) response.setHeader("ETag", resourceEtag.toString());

    throw new PreconditionFailedException("If-Match disallows conditional request");
  }
Esempio n. 2
0
  private void ifNoneMatch(DavRequest request, DavResponse response, DavResource resource)
      throws DavException, IOException {
    EntityTag[] requestEtags = request.getIfNoneMatch();
    if (requestEtags.length == 0) return;

    EntityTag resourceEtag = etag(resource);
    if (resourceEtag == null) return;

    if (!EntityTag.matchesAny(resourceEtag, requestEtags)) return;

    if (resourceEtag != null) response.addHeader("ETag", resourceEtag.toString());

    if (deservesNotModified(request)) throw new NotModifiedException();
    else throw new PreconditionFailedException("If-None-Match disallows conditional request");
  }