@Override protected void describeMismatchSafely(Response<T> item, Description mismatchDescription) { mismatchDescription.appendText("it contained headers ").appendValue(item.headerEntries()); } };
@Override protected boolean matchesSafely(Response<T> item) { return !item.headerEntries().iterator().hasNext(); }
/** * A header of the request message, looked up in a case insensitive way, * or empty if no header with that name is found. */ default Optional<String> header(String name) { Objects.requireNonNull(name, "Header names cannot be null"); for (Map.Entry<String, String> headerEntry : headerEntries()) { if (name.equalsIgnoreCase(headerEntry.getKey())) { return Optional.ofNullable(headerEntry.getValue()); } } return Optional.empty(); }
private void sendReply(Response<ByteString> response) { if (!replied.compareAndSet(false, true)) { LOGGER.warn("Already replied to ongoing request {} - spurious response {}", request, response); } else { final HttpServletResponse httpResponse = (HttpServletResponse) asyncContext.getResponse(); final StatusType status = response.status(); httpResponse.setStatus(status.code(), status.reasonPhrase()); response.headerEntries().forEach(entry -> httpResponse.addHeader(entry.getKey(), entry.getValue())); response.payload().ifPresent(payload -> { try { payload.write(httpResponse.getOutputStream()); } catch (IOException e) { LOGGER.warn("Failed to write response", e); } }); asyncContext.complete(); logger.accept(this, Optional.of(response)); } }
@Override protected void describeMismatchSafely(Response<T> item, Description mismatchDescription) { mismatchDescription.appendText("it contained headers ").appendValue(item.headerEntries()); } };
@Override protected boolean matchesSafely(Response<T> item) { return !item.headerEntries().iterator().hasNext(); }
/** * A header of the request message, looked up in a case insensitive way, * or empty if no header with that name is found. */ default Optional<String> header(String name) { Objects.requireNonNull(name, "Header names cannot be null"); for (Map.Entry<String, String> headerEntry : headerEntries()) { if (name.equalsIgnoreCase(headerEntry.getKey())) { return Optional.ofNullable(headerEntry.getValue()); } } return Optional.empty(); }