@SuppressWarnings("unchecked") public ClientResponse proceed() throws Exception { if (index >= interceptors.size()) { return executor.execute(request); } else { try { return interceptors.get(index++).execute(this); } finally { index--; } } } }
@Override public void close() throws IOException { try { clientExecutor.close(); } catch (Exception e) { // Silently skip errors in the socket close errors } try { super.close(); } catch (SocketException e) { // We expect this exception because the socket is closed } catch (IllegalStateException e) { // We expect this exception because the socket is closed (httpclient 4.2) } }
@Ignore("TODO") @Test public void follow_get() throws Exception { final LinkRepresentation link = jsonRepresentation.getLink("aLink"); final String href = link.getHref(); // when context.checking(new Expectations() { { one(mockExecutor).createRequest(with(any(UriBuilderImpl.class))); will(returnValue(mockClientRequest)); one(mockExecutor).execute(mockClientRequest); will(returnValue(mockClientResponse)); one(mockClientRequest).accept(MediaType.APPLICATION_JSON_TYPE); atLeast(1).of(mockClientRequest).setHttpMethod("GET"); allowing(mockClientRequest).getHttpMethod(); will(returnValue("GET")); one(mockClientRequest).execute(); will(returnValue(mockClientResponse)); one(mockClientResponse).setReturnType(String.class); allowing(mockClientResponse); final MultiValueMap result = new MultiValueMap(); result.put("Content-Type", "application/json"); allowing(mockClientResponse).getMetadata(); will(returnValue(result)); } }); final RestfulResponse<JsonRepresentation> response = client.follow(link); // then }
public static ClientRequestConfigurer create(final ClientExecutor executor, final String uriTemplate) { final UriBuilder uriBuilder = new UriBuilderImpl().uriTemplate(uriTemplate); final ClientRequest clientRequest = executor.createRequest(uriBuilder); return new ClientRequestConfigurer(clientRequest, uriBuilder); }
public static ClientRequestConfigurer create(final ClientExecutor executor, final String uriTemplate) { final UriBuilder uriBuilder = new UriBuilderImpl().uriTemplate(uriTemplate); final ClientRequest clientRequest = executor.createRequest(uriBuilder); return new ClientRequestConfigurer(clientRequest, uriBuilder); }
@SuppressWarnings("unchecked") public ClientResponse proceed() throws Exception { if (index >= interceptors.size()) { return executor.execute(request); } else { try { return interceptors.get(index++).execute(this); } finally { index--; } } } }
public void closeConnection() { try { if (clientResponse != null) { clientResponse.releaseConnection(); } if (clientRequest != null && clientRequest.getExecutor() != null) { clientRequest.getExecutor().close(); } } catch (Exception e) { LOG.error(e.getMessage(), e); } }
if (getExecutionInterceptorList().isEmpty()) response = (BaseClientResponse) executor.execute(this);
if (getExecutionInterceptorList().isEmpty()) response = (BaseClientResponse) executor.execute(this);