response = builder.delete( ClientResponse.class ); } else if ( data.method.equals( RestMeta.HTTP_METHOD_HEAD ) ) { response = builder.head(); } else if ( data.method.equals( RestMeta.HTTP_METHOD_OPTIONS ) ) { response = builder.options( ClientResponse.class );
/** * Returns the head for the given doc * * @param docId the doc * @return the head for the given doc id */ @Nonnull public ClientResponse getHead( @Nonnull DocId docId ) { WebResource.Builder path = getDbRoot().path( docId.asString() ).type( JSON_TYPE ).accept( JSON_TYPE ); if ( LOG.isLoggable( Level.FINE ) ) { LOG.fine( "HEAD " + path.toString() ); } return path.head(); }
/** * Returns the head for the given attachment * * @param docId the doc id * @param attachmentId the attachment id * @return the response */ @Nonnull public ClientResponse getHead( @Nonnull DocId docId, @Nonnull AttachmentId attachmentId ) { WebResource.Builder path = getDbRoot() .path( docId.asString() ) .path( attachmentId.asString() ) .type( JSON_TYPE ).accept( JSON_TYPE ); if ( LOG.isLoggable( Level.FINE ) ) { LOG.fine( "HEAD " + path.toString() ); } return path.head(); }
break; case HEAD: jerseyResponse = b.head(); break; case OPTIONS:
response = builder.head(); status = response.getClientResponseStatus();
ClientResponse rsp = builder.head(); if ((rsp.getStatus() != Response.Status.OK.getStatusCode())) { throw new AssertionError("No acceptable resource available at "
response = builder.type(contentType).header("X-HTTP-Method-Override", "PATCH").post(ClientResponse.class, serialize(body, contentType, formParams)); } else if ("HEAD".equals(method)) { response = builder.head(); } else { throw new ApiException(500, "unknown method type " + method);
final ClientResponse response = getNexusClient().uri( uri ).head(); if ( !ClientResponse.Status.OK.equals( response.getClientResponseStatus() ) )
/** * get a response for the given url and method * * @param url * @param method * @return * @throws Exception */ public ClientResponse getResponse(String url, Method method) throws Exception { Builder resource = getResource(url); ClientResponse response = null; switch (method) { case Get: response = resource.get(ClientResponse.class); break; case Post: response = resource.post(ClientResponse.class); break; case Head: response = resource.head(); break; case Put: response = resource.put(ClientResponse.class); break; } return response; }
@Override public Date getLastModified( final String uri ) { try { final ClientResponse response = getNexusClient() .uri( uri ) .head(); return response.getLastModified(); } catch ( ClientHandlerException e ) { throw getNexusClient().convert( e ); } } }
public ClientResponse head(WebResource webResource) { return decorate(webResource).head(); }
@Override public EmoResponse head() { return toEmoResponse(builder().head()); }
@Override public EmoResponse head() { return toEmoResponse(builder().head()); }
@Override public EmoResponse head() { return toEmoResponse(builder().head()); }
@Test public void testHeadURL() throws Exception { Client client = createTestClient(); WebResource webResource = client.resource(base_url); ClientResponse response = webResource.type(MediaType.APPLICATION_JSON) .head(); assertEquals(200, response.getStatus()); }
@Override public boolean isHealthy(ServiceEndPoint endPoint) { URI adminUrl = Payload.valueOf(endPoint.getPayload()).getAdminUrl(); return _jerseyClient.resource(adminUrl).path("/healthcheck") .header(HttpHeaders.CONNECTION, "close") .head().getStatus() == 200; } }
@Override public boolean isHealthy(ServiceEndPoint endPoint) { URI adminUrl = Payload.valueOf(endPoint.getPayload()).getAdminUrl(); return _jerseyClient.resource(adminUrl).path("/healthcheck") .header(HttpHeaders.CONNECTION, "close") .head().getStatus() == 200; } }
@Test public void testAllowedMethod() throws Exception { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("cluster") .path("info").accept("application/xml") .header(RestCsrfPreventionFilter.HEADER_USER_AGENT,"Mozilla/5.0") .head(); assertTrue("Should have been allowed", response.getStatus() == Status.OK.getStatusCode()); }
@Test public void testHeadURL() throws Exception { Client client = createTestClient(); WebResource webResource = client.resource(base_url); ClientResponse response = webResource.type(MediaType.APPLICATION_JSON) .head(); assertEquals(200, response.getStatus()); }