private String getHeaderValue(Response resp, String headerName) { Map<String, Collection<String>> headers = resp.headers(); Collection<String> values = headers.get(headerName); String value = null; if (values != null && values.isEmpty() == false) { String[] array = new String[values.size()]; values.toArray(array); value = array[0]; } return value; }
private String getHeaderValue(Response resp, String headerName) { Map<String, Collection<String>> headers = resp.headers(); Collection<String> values = headers.get(headerName); String value = null; if (values != null && values.isEmpty() == false) { String[] array = new String[values.size()]; values.toArray(array); value = array[0]; } return value; }
@Override public Map<String, Collection<String>> getHeaders() { return this.response.headers(); }
private String getHeaderValue(Response resp, String headerName) { Map<String, Collection<String>> headers = resp.headers(); Collection<String> values = headers.get(headerName); String value = null; if (values != null && values.isEmpty() == false) { String[] array = new String[values.size()]; values.toArray(array); value = array[0]; } return value; }
private String getHeaderValue(Response resp, String headerName) { Map<String, Collection<String>> headers = resp.headers(); Collection<String> values = headers.get(headerName); String value = null; if (values != null && values.isEmpty() == false) { String[] array = new String[values.size()]; values.toArray(array); value = array[0]; } return value; }
@Override public HttpHeaders getHeaders() { return HttpHeadersUtils.getHttpHeaders(response.headers()); } }
private static HttpHeaders cloneHeaders(final feign.Response response) { final HttpHeaders responseHeaders = new HttpHeaders(); response.headers().entrySet().stream() .forEach(entry -> responseHeaders.put(entry.getKey(), newArrayList(entry.getValue()))); return responseHeaders; }
@Override public HttpHeaders getHeaders() { final HttpHeaders responseHeaders = new HttpHeaders(); response.headers().entrySet().stream() // .forEach(entry -> responseHeaders.put(entry.getKey(), Lists.newArrayList(entry.getValue()))); return responseHeaders; } }
private static HttpHeaders cloneHeaders(final feign.Response response) { final HttpHeaders responseHeaders = new HttpHeaders(); response.headers().entrySet().stream() .forEach(entry -> responseHeaders.put(entry.getKey(), newArrayList(entry.getValue()))); return responseHeaders; }
@Override public HttpHeaders getHeaders() { final HttpHeaders responseHeaders = new HttpHeaders(); response.headers().entrySet().stream() // .forEach(entry -> responseHeaders.put(entry.getKey(), Lists.newArrayList(entry.getValue()))); return responseHeaders; } }
static Map<String, String> extractHeaders(Response response) { return response.headers().entrySet().stream().collect(Collectors.toMap( e -> e.getKey(), e -> StringUtils.collectionToCommaDelimitedString(e.getValue()) )); }
@SuppressWarnings("unchecked") private <T> ResponseEntity<T> createResponse(Object instance, Response response) { MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); for (String key : response.headers().keySet()) { headers.put(key, new LinkedList<>(response.headers().get(key))); } return new ResponseEntity<>((T) instance, headers, HttpStatus.valueOf(response .status())); } }
@SuppressWarnings("unchecked") private <T> ResponseEntity<T> createResponse(Object instance, Response response) { MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); for (String key : response.headers().keySet()) { headers.put(key, new LinkedList<>(response.headers().get(key))); } return new ResponseEntity<>((T) instance, headers, HttpStatus.valueOf(response .status())); } }
@Override public Object decode(Response response, Type type) throws IOException, FeignException { Collection<String> contentTypeHeaders = response.headers().get(CONTENT_TYPE); String responseContentType = contentTypeHeaders != null ? contentTypeHeaders.iterator().next() : MediaType.TEXT_PLAIN; if (responseContentType.equals(MediaType.APPLICATION_JSON)) { return gsonDecoder.decode(response, type); } else if (responseContentType.equals(MediaType.TEXT_PLAIN) || responseContentType.equals(MediaType.WILDCARD)) { return stringDecoder.decode(response, type); } throw new RuntimeException("Unsupported Content Type " + responseContentType); } }
@SuppressWarnings({"unchecked"}) private <T> ResponseEntity<T> createResponse(final Object instance, final Response response) { final MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); for (final String key : response.headers().keySet()) { headers.put(key, createLintedList(response.headers().get(key))); } return new ResponseEntity<>((T) instance, headers, HttpStatus.valueOf(response.status())); }
@Override public Object decode(Response response, Type type) throws IOException, DecodeException, FeignException { Collection<String> contentTypes = response.headers().get("Content-Type"); if (contentTypes.contains(MimeTypeUtils.TEXT_PLAIN.toString())) { return defaultDecoder.decode(response, type); } else { return gsonDecoder.decode(response, type); } } }
@Override public Exception decode(String methodKey, Response response) { FeignException exception = errorStatus(methodKey, response); Date retryAfter = retryAfterDecoder.apply(firstOrNull(response.headers(), RETRY_AFTER)); if (retryAfter != null) { return new RetryableException(exception.getMessage(), exception, retryAfter); } return exception; }
@Test public void execute_NullResponseHeadersGiven_ShouldRespondWithEmptyHeaders() throws IOException { FeignLambdaClientImpl client = new FeignLambdaClientImpl(serviceResponse); when(serviceResponse.getHeaders()).thenReturn(null); feign.Response response = client.execute(feignRequest, null); assertEquals(Collections.emptyMap(), response.headers()); }
public RibbonResponseStatusCodeException(String serviceId, Response response, byte[] body, URI uri) { super(serviceId, response.status(), response, uri); this.response = Response.builder().body(new ByteArrayInputStream(body), body.length) .headers(response.headers()).reason(response.reason()) .status(response.status()).request(response.request()).build(); }
public RibbonResponseStatusCodeException(String serviceId, Response response, byte[] body, URI uri) { super(serviceId, response.status(), response, uri); this.response = Response.builder().body(new ByteArrayInputStream(body), body.length) .headers(response.headers()).reason(response.reason()) .status(response.status()).request(response.request()).build(); }