@Override public boolean message(CharSequence topic, ChannelReader payload) { if (responder.readHandoffData(payload)) { return responder.respondWith(200, false, HTTPContentTypeDefaults.TXT, (w)->{w.writeUTF("sent by responder");}); } else { return false; } }
/** * * @param statusCode int arg used in commandChannel.publishHTTPResponse * @param hasContinuation boolean arg * @param contentType HTTPContentType arg used in commandChannel.publishHTTPResponse * @param writable Writable arg used in commandChannel.publishHTTPResponse * @return publishResult if connectionId GTE 0 AND sequenceCode GTE 0 <p> <code>false</code> if Pipe.hasContentToRead(pipe) else <code>true</code> */ public boolean respondWith(int statusCode, boolean hasContinuation, HTTPContentType contentType, Writable writable) { return respondWith(statusCode, hasContinuation, null, contentType, writable); }
@Override public boolean responseHTTP(HTTPResponseReader reader) { if (reader.isConnectionClosed()) { return responder.closed(); } else { return responder.respondWith(200, !reader.isEndOfResponse(), (headWriter) -> { reader.structured().visit(HTTPHeader.class, (header,r,id)->{ //we are a proxy, our response has its own length, connection and status if (header != HTTPHeaderDefaults.CONTENT_LENGTH && header != HTTPHeaderDefaults.CONNECTION && header != HTTPHeaderDefaults.STATUS ) { headWriter.write(header, reader.getSpec(), r); } }); }, reader.contentType(), (payloadWriter) -> { payloadWriter.write(reader.structured().readPayload()); }); } }
public ExternalResponse(GreenRuntime runtime) { responder = new HTTPResponder(runtime.newCommandChannel(), 300); }
@Override public boolean message(CharSequence topic, ChannelReader payload) { return responder.readHandoffData(payload); }
clearAll(); clearAll(); if (publishCanceledResponse()) { clearAll(); return true; } else {
public HTTPResponder(MsgCommandChannel<?> commandChannel, int maximumPayloadSize) { clearAll(); int maximumMessages = 4; this.responseService = commandChannel.newHTTPResponseService(maximumMessages, maximumPayloadSize); }
public boolean respondWith(boolean hasContinuation, HeaderWritable headers, HTTPContentType contentType, Writable writable) { return respondWith(200,hasContinuation,headers,contentType,writable); }
public RestBehaviorHandoffResponder(GreenRuntime runtime, AppendableProxy console) { responder = new HTTPResponder(runtime.newCommandChannel(),256*1024); }
private boolean publishCanceledResponse() { //send the cancel response.... if (responseService.publishHTTPResponse( connectionId, sequenceCode, cancelStatusCode, false, cancelHeaderWritable, cancelType, cancelPayload)) { //keep in case we see it again. lastCancelledConnectionId = connectionId; clearAll(); return true; } else { return false; } }
@Override public boolean message(CharSequence topic, ChannelReader payload) { boolean result = responder.readHandoffData(payload); if (result) { responder.respondWith(200, false, HTTPContentTypeDefaults.TXT, (w)->{w.writeUTF8Text("sent by responder");}); } return result; }
public RestBehaviorHandoffResponder(GreenRuntime runtime, AppendableProxy console) { responder = new HTTPResponder(runtime.newCommandChannel(), 256*1024); }