public boolean publishHTTPResponse(long connectionId, long sequenceCode, int statusCode, HTTPContentType contentType, Writable writable) { return publishHTTPResponse(connectionId, sequenceCode, statusCode, false, contentType, writable); } /**
@Override public boolean restRequest(HTTPRequestReader request) { if (request.structured().isEqual(keyFieldId, pass)) { if (!responseService.hasRoomFor(2)) {//reponse then shutdown return false; } if (responseService.publishHTTPResponse(request, 200)) { responseService.requestShutdown(); return true; } return false; } else { if (responseService.publishHTTPResponse(request, 404)) { return true; } return false; } }
/** * * @return new HTTPResponseService */ public HTTPResponseService newHTTPResponseService() { return new HTTPResponseService(this); }
@Override public boolean restRequest(HTTPRequestReader request) { if (request.structured().isEqual(keyFieldId, PASS1)) { if (channel.publishHTTPResponse(request, 200)) { channel.requestShutdown(); hasFirstKey = true; System.out.println("first key"); return true; } } else if (hasFirstKey && request.structured().isEqual(keyFieldId, PASS2)) { if (channel.publishHTTPResponse(request, 200)) { hasSecondKey = true; System.out.println("second key"); return true; } } else { return channel.publishHTTPResponse(request, 404); } return false; }
boolean okA = cmd.publishHTTPResponse(request, 200, true, HTTPContentTypeDefaults.TXT, boolean okB = cmd.publishHTTPResponseContinuation(request, false, (writer)-> {
int roomForWrite = service.maxVarLength(); boolean hasContinuation = bytesRemaining >roomForWrite; if (0 == htmlFortunePos) { ok = service.publishHTTPResponse(t.getConnectionId(), t.getSequenceId(), 200, hasContinuation, HTTPContentTypeDefaults.HTML, w-> { ok =service.publishHTTPResponseContinuation(t.getConnectionId(), t.getSequenceId(), hasContinuation, w-> { htmlFortunePos += htmlFortuneBuffer.copyTo(w,htmlFortunePos);
public boolean jsonRestRequest(HTTPRequestReader request) { //this check is to postpone the work if the network has become saturated if (responseService.hasRoomFor(1)) { //NOTE: this is only done here for the framework test // in a normal production deployment this JSONRender will only // be created once and held as a member. JSONRenderer<HTTPRequestReader> renderJSON = new JSONRenderer<HTTPRequestReader>() .startObject() .string(messageBytes, (o,t) -> t.write(FrameworkTest.payload) ) .endObject(); return responseService.publishHTTPResponse(request, HTTPContentTypeDefaults.JSON, w -> renderJSON.render(w,request) ); } else { return false; } }
/** * * @param w HTTPFieldReader arg used in publishHTTPResponseContinuation * @param hasContinuation boolean arg used in publishHTTPResponseContinuation * @param writable Writable arg used in publishHTTPResponseContinuation * @return publishHTTPResponseContinuation(w.getConnectionId(),w.getSequenceCode(), hasContinuation, writable) */ public boolean publishHTTPResponseContinuation(HTTPFieldReader<?> w, boolean hasContinuation, Writable writable) { return publishHTTPResponseContinuation(w.getConnectionId(),w.getSequenceCode(), hasContinuation, writable); }
boolean okA = cmd.publishHTTPResponse(request, 200, true, HTTPContentTypeDefaults.TXT, boolean okB = cmd.publishHTTPResponseContinuation(request, false, (writer)-> {
public boolean plainRestRequest(HTTPRequestReader request) { return responseService.publishHTTPResponse(request, HTTPContentTypeDefaults.PLAIN, w -> w.write(FrameworkTest.payload) ); }
@Override public boolean restRequest(HTTPRequestReader request) { if (request.structured().isEqual(Field.KEY, pass)) { if (!responseService.hasRoomFor(2)) {//reponse then shutdown return false; } if (responseService.publishHTTPResponse(request, 200)) { responseService.requestShutdown(); return true; } return false; } else { if (responseService.publishHTTPResponse(request, 404)) { return true; } return false; } }
/** * * @param queueLength int arg to be passed to HTTPResponseService * @return new HTTPResponseService */ public HTTPResponseService newHTTPResponseService(int queueLength) { return new HTTPResponseService(this,queueLength,0); }
@Override public boolean restRequest(HTTPRequestReader request) { return responseService.publishHTTPResponse(request, 200, HTTPContentTypeDefaults.PLAIN, (w)-> w.append("Hello World") ); }
/** * * @param queueLength int arg to be passed to HTTPResponseService * @param maxMessageSize int arg to be passed to HTTPResponseService * @return new HTTPResponseService */ public HTTPResponseService newHTTPResponseService(int queueLength, int maxMessageSize) { return new HTTPResponseService(this,queueLength,maxMessageSize); }
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; } }
public boolean publishHTTPResponse(HTTPFieldReader<?> reqeustReader, HTTPContentType contentType, Writable writable) { return publishHTTPResponse(reqeustReader.getConnectionId(), reqeustReader.getSequenceCode(), 200, false, null, contentType, writable); }
/** * * @param requestReader HTTPFieldReader arg used in publishHTTPResponse * @param statusCode int arg used in publishHTTPResponse * @return HTTPResponse with given args */ public boolean publishHTTPResponse(HTTPFieldReader<?> requestReader, int statusCode) { assert((0 != (msgCommandChannel.initFeatures & MsgCommandChannel.NET_RESPONDER))) : "CommandChannel must be created with NET_RESPONDER flag"; //logger.info("Building response for connection {} sequence {} ",w.getConnectionId(),w.getSequenceCode()); return publishHTTPResponse(requestReader.getConnectionId(), requestReader.getSequenceCode(), statusCode,false,null,Writable.NO_OP); //no type and no body so use null }
/** * * @param reqeustReader HTTPFieldReader arg used in publishHTTPResponse * @param headers HeaderWritable arg used in publishHTTPResponse * @param writable Writable arg used in publishHTTPResponse * @return publishHTTPResponse(reqeustReader.getConnectionId (), reqeustReader.getSequenceCode(), * false, headers, 200, writable) */ public boolean publishHTTPResponse(HTTPFieldReader reqeustReader, HeaderWritable headers, HTTPContentType contentType, Writable writable) { return publishHTTPResponse(reqeustReader.getConnectionId(), reqeustReader.getSequenceCode(), 200, false, headers, contentType, writable); }
if (connectionId>=0 && sequenceCode>=0) { if (null!=headers) { if (responseService.publishHTTPResponse(connectionId, sequenceCode, statusCode, hasContinuation, headers, contentType, writable)) { if (responseService.publishHTTPResponse(connectionId, sequenceCode, statusCode, hasContinuation, contentType, writable)) {
/** * * @param requestReader HTTPFieldReader arg used in publishHTTPResponse * @param statusCode int used as arg in publishHTTPResponse * @param contentType HTTPContentType used as arg in publishHTTPResponse * @param writable Writable used as arg in publishHTTPResponse * @return HTTPResponse with given args */ public boolean publishHTTPResponse(HTTPFieldReader<?> requestReader, int statusCode, HTTPContentType contentType, Writable writable) { assert((0 != (msgCommandChannel.initFeatures & MsgCommandChannel.NET_RESPONDER))) : "CommandChannel must be created with NET_RESPONDER flag"; return publishHTTPResponse(requestReader.getConnectionId(), requestReader.getSequenceCode(), statusCode, false, contentType, writable); }