@Override public String getHeader(final String name) { final List<String> option = playDelegate.getHeaders().getAll(name); return option != null && !option.isEmpty() ? option.iterator().next() : null; }
@Override public Enumeration<String> getHeaderNames() { return enumeration(playDelegate.getHeaders().toMap().keySet()); }
@Override public Enumeration<String> getHeaders(final String name) { return enumeration(playDelegate.getHeaders().getAll(name)); }
@Override public Accumulator<ByteString, Result> apply(final Http.RequestHeader requestHeader) { return state.getServletContext().findMatchingServlet(requestHeader).map(servlet -> { final long length = requestHeader.getHeaders().get("Content-Length").map(Long::parseLong) .orElse(Long.MAX_VALUE); final BodyParser.Bytes slurper = new BodyParser.Bytes(length, state.getHttpErrorHandler()); return slurper.apply(requestHeader).mapFuture( resultOrBytes -> resultOrBytes.left.map(CompletableFuture::completedFuture).orElseGet(() -> { return state.getServletContext() .executeInvoke(servlet, requestHeader, resultOrBytes.right.get().iterator().asInputStream(), servlet.getServletPath()) .toCompletableFuture(); }), state.getServletContext().getDefaultExecutor()); }).orElseGet(() -> next.apply(requestHeader)); } };
/** * Checks if the request has the header. * * @param headerName The name of the header (case-insensitive) * @return <code>true</code> if the request did contain the header. */ default boolean hasHeader(String headerName) { return getHeaders().contains(headerName); }
/** * Checks if the request has the header. * * @param headerName The name of the header (case-insensitive) * @return <code>true</code> if the request did contain the header. */ default boolean hasHeader(String headerName) { return getHeaders().contains(headerName); }
/** * Retrieves a single header. * * @param headerName The name of the header (case-insensitive) * @return the value corresponding to <code>headerName</code>, or empty if it was not present */ default Optional<String> header(String headerName) { return getHeaders().get(headerName); }
/** * Retrieves a single header. * * @param headerName The name of the header (case-insensitive) * @return the value corresponding to <code>headerName</code>, or empty if it was not present */ default Optional<String> header(String headerName) { return getHeaders().get(headerName); }
/** * Retrieves a single header. * * @param headerName The name of the header (case-insensitive) * @return the value corresponding to <code>headerName</code>, or empty if it was not present */ default Optional<String> header(String headerName) { return getHeaders().get(headerName); }
/** * Checks if the request has the header. * * @param headerName The name of the header (case-insensitive) * @return <code>true</code> if the request did contain the header. */ default boolean hasHeader(String headerName) { return getHeaders().contains(headerName); }