/** * Report the boolean success of this event. * For default-format functions, this is used to map the HTTP status code into a straight success/failure. * * @return true if the output event results from a successful invocation. */ default boolean isSuccess() { return getStatus() == Status.Success; }
@Override public Status getStatus() { return from.getStatus(); }
@Override public Status getStatus() { return a.getStatus(); }
private void writeEvent(OutputEvent evt, HttpResponse response) { evt.getHeaders().asMap() .entrySet() .stream() .filter(e -> !stripOutputHeaders.contains(e.getKey())) .flatMap(e -> e.getValue().stream().map((v) -> new BasicHeader(e.getKey(), v))) .forEachOrdered(response::addHeader); ContentType contentType = evt.getContentType().map(c -> { try { return ContentType.parse(c); } catch (ParseException e) { return ContentType.DEFAULT_BINARY; } }).orElse(ContentType.DEFAULT_BINARY); response.setHeader("Content-Type", contentType.toString()); response.setStatusLine(new BasicStatusLine(HttpVersion.HTTP_1_1, evt.getStatus().getCode(), evt.getStatus().name())); ByteArrayOutputStream bos = new ByteArrayOutputStream(); // TODO remove output buffering here - possibly change OutputEvent contract to support providing an InputStream? try { evt.writeToOutput(bos); } catch (IOException e) { throw new FunctionOutputHandlingException("Error writing output", e); } byte[] data = bos.toByteArray(); response.setEntity(new ByteArrayEntity(data, contentType)); }