@Override public String header(String name) { return response.getHeaders().getFirst(name).toString(); }
@Override public Map<String, String> headers() { Map<String, String> headers = new HashMap<String, String>(); MultivaluedMap<String, Object> responseHeaders = response.getHeaders(); for (String key : responseHeaders.keySet()) { headers.put(key, responseHeaders.getFirst(key).toString()); } return headers; }
protected void cacheIfPossible(final ClientRequest request, final ClientResponse<?> response) throws Exception { if (response.getStatus() == 200) { final String uri = request.getUri(); final String etag = (String) response.getHeaders().getFirst(HttpHeaders.ETAG); final String contentType = (String) response.getHeaders().getFirst(HttpHeaders.CONTENT_TYPE); if (etag != null && !etag.trim().isEmpty()) { cache.put(uri, etag, contentType); } } } }
protected void initialize() throws Exception { super.start(); initialized = true; initAuthentication(); ClientRequest request = executor.createRequest(registration.getTarget().getHref()); for (XmlHttpHeader header : registration.getHeaders()) { request.header(header.getName(), header.getValue()); } ClientResponse<?> res = request.head(); if (res.getStatus() != 200) { throw new RuntimeException("Failed to query REST destination for init information. Status: " + res.getStatus()); } String url = (String) res.getHeaders().getFirst("msg-create-with-id"); if (url == null) { if (res.getLinkHeader() == null) { throw new RuntimeException("Could not find create-with-id URL"); } Link link = res.getLinkHeader().getLinkByTitle("create-with-id"); if (link == null) { throw new RuntimeException("Could not find create-with-id URL"); } url = link.getHref(); } targetUri = ResteasyUriBuilder.fromTemplate(url); }
protected void initialize() throws Exception { super.start(); initialized = true; initAuthentication(); ClientRequest request = executor.createRequest(registration.getTarget().getHref()); for (XmlHttpHeader header : registration.getHeaders()) { request.header(header.getName(), header.getValue()); } ClientResponse<?> res = request.head(); if (res.getStatus() != 200) { throw new RuntimeException("Failed to query REST destination for init information. Status: " + res.getStatus()); } String url = (String) res.getHeaders().getFirst("msg-create-with-id"); if (url == null) { if (res.getLinkHeader() == null) { throw new RuntimeException("Could not find create-with-id URL"); } Link link = res.getLinkHeader().getLinkByTitle("create-with-id"); if (link == null) { throw new RuntimeException("Could not find create-with-id URL"); } url = link.getHref(); } targetUri = ResteasyUriBuilder.fromTemplate(url); }
String url = (String)res.getHeaders().getFirst("msg-create-with-id"); if (url == null)
getResponse().setHeaders(clientResponse.getMetadata()); if (StringUtils.isNotBlank(entity)) { List<Object> contentType = clientResponse.getHeaders().get("Content-Type"); if (contentType != null && contentType.contains("application/jwt")) { String[] jwtParts = entity.split("\\.");