/** * <p>Factory method for creating a ResponseDispatch with a {@link Response} that has the given status code, and * ByteBuffer content.</p> * * @param responseStatus The status code of the Response to dispatch. * @param content The ByteBuffer content of the Response, may be empty. * @return The created ResponseDispatch. */ public static ResponseDispatch newInstance(int responseStatus, ByteBuffer... content) { return newInstance(new Response(responseStatus), Arrays.asList(content)); }
/** * <p>Factory method for creating a ResponseDispatch with a {@link Response} that has the given status code, and * collection of ByteBuffer content. * Because this method uses the Iterable interface, you can create the ByteBuffers lazily, or * provide them as they become available.</p> * * @param responseStatus The status code of the Response to dispatch. * @param content The provider of the Response's ByteBuffer content. * @return The created ResponseDispatch. */ public static ResponseDispatch newInstance(int responseStatus, Iterable<ByteBuffer> content) { return newInstance(new Response(responseStatus), content); }
@Override protected com.yahoo.jdisc.Response newResponse() { com.yahoo.jdisc.Response response = new com.yahoo.jdisc.Response(com.yahoo.jdisc.Response.Status.OK); response.headers().add("Content-Type", Arrays.asList(new String[]{"application/json"})); return response; } }.connect(handler));
@Override protected com.yahoo.jdisc.Response newResponse() { com.yahoo.jdisc.Response response = new com.yahoo.jdisc.Response(statusToReturn); response.headers().add("Content-Type", Arrays.asList(new String[]{"application/json"})); return response; } }.connect(handler));
@Override protected Response newResponse() { Response response = new Response(Response.Status.OK); response.headers().add(HttpHeaders.Names.CONTENT_TYPE, "application/json"); return response; }
@Override public ContentChannel handle(Request request, ResponseHandler handler) { ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); out.close(EXCEPTION_COMPLETION_HANDLER); return null; } });
protected void respondNoContent(final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); closeResponse(out); }
@Override public ContentChannel handle(Request request, ResponseHandler handler) { ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); writeResponse(out); out.close(EXCEPTION_COMPLETION_HANDLER); return null; } });
protected void respondWithContent(final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); writeResponse(out); closeResponse(out); }
@Override public ContentChannel handle(final Request request, final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); writeResponse(out); closeResponseInOtherThread(out); return null; } });
@Override public ContentChannel handle(final Request request, final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); writeResponse(out); closeResponse(out); return null; } });
@Override public ContentChannel handle(final Request request, final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); callInOtherThread(() -> { closeResponse(out); return null; }); return new ContentChannel() { @Override public void write(final ByteBuffer buf, final CompletionHandler handler) { responseClosed.await(); throw new ConformanceException(); } @Override public void close(final CompletionHandler handler) { handler.completed(); } }; } });
@Override public ContentChannel handle(final Request request, final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); writeResponse(out); closeResponse(out); throw new ConformanceException(); } });
@Override protected Response newResponse() { Response response = new Response(Response.Status.OK); response.headers().add(HttpHeaders.Names.CONTENT_TYPE, resolveContentType(request.getUri())); return response; }
@Override public ContentChannel handle(final Request request, final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); callInOtherThread(() -> { writeResponse(out); closeResponse(out); return null; }); return null; } });
@Override public ContentChannel handle(final Request request, final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); writeResponse(out); closeResponseInOtherThread(out); throw new ConformanceException(); } });
@Override public ContentChannel handle(Request request, ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); for (ByteBuffer buf : adapter.newResponseContent()) { out.write(buf, EXCEPTION_COMPLETION_HANDLER); } closeResponse(out); return null; } });
@Override public ContentChannel handle(final Request request, final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); callInOtherThread(() -> { writeResponse(out); closeResponse(out); return null; }); throw new ConformanceException(); } });
@Override public ContentChannel handle(final Request request, final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); callInOtherThread(() -> { writeResponse(out); closeResponse(out); return null; }); responseWritten.await(); throw new ConformanceException(); } });
@Override public ContentChannel handle(final Request request, final ResponseHandler handler) { final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK)); final Event exceptionHandledByFramework = new Event(); callInOtherThread(() -> { exceptionHandledByFramework.await(); writeResponse(out); closeResponse(out); return null; }); throw new ConformanceException(exceptionHandledByFramework); } });