@Override public void finish(Pipe<ServerResponseSchema> output) { ChannelWriter outputStream = HTTPUtilResponse.openHTTPPayload(ebh, output, channelId, sequence); outputStream.append(payloadBuffer); HeaderWritable additionalHeaderWriter = null; HTTPUtilResponse.closePayloadAndPublish( ebh, null, HTTPContentTypeDefaults.JSON, output, channelId, sequence, context, outputStream, additionalHeaderWriter, 200); }
private static void writeHeaderAndPublish(int statusCode, HeaderWritable headers, HTTPContentType contentType, Pipe<ServerResponseSchema> pipe, NetResponseWriter outputStream, int len, MsgCommandChannel<?> msgCommandChannel) { ////////////////////Write the header HTTPUtilResponse.openToEmptyBlock(msgCommandChannel.data, outputStream); outputStream.write(HTTPRevisionDefaults.HTTP_1_1.getBytes()); outputStream.write(HTTPResponseStatusCodes.codes[statusCode]); //this is " 200 OK\r\n" for most calls writeDateTimeHeader(outputStream); writeHeadersWithHeaderWriter(headers, contentType, outputStream, len, msgCommandChannel.headerWriter.target(outputStream)); HTTPUtilResponse.finalizeLengthOfFirstBlock(msgCommandChannel.data, outputStream); //now publish both header and payload Pipe.publishWrites(pipe); }
public static ChannelWriter openHTTPPayload( HTTPUtilResponse that, Pipe<ServerResponseSchema> output, long activeChannelId, int activeSequenceNo) { HTTPUtilResponse.holdEmptyBlock(that, activeChannelId, activeSequenceNo, output); return Pipe.openOutputStream(output); }
public static void closePayloadAndPublish( HTTPUtilResponse that, byte[] eTag, HTTPContentType contentTypeEnum, Pipe<ServerResponseSchema> output, long activeChannelId, int activeSequenceNo, int activeFieldRequestContext, ChannelWriter outputStream, HeaderWritable additionalHeaderWriter, int status) { storeChnlAndSeqInHeaderFragment(that, output, activeChannelId, activeSequenceNo); byte[] contentType = null!=contentTypeEnum ? contentTypeEnum.getBytes() : null; int totalLengthWritten = outputStream.length(); //this is a key pronghorn pattern in use here output.closeBlobFieldWrite(); //closed because we will add each part below... HTTPUtil.prependBodyWithHeader(output, eTag, totalLengthWritten, that, activeFieldRequestContext, activeChannelId, activeSequenceNo, contentType, additionalHeaderWriter, status);//context }
ChannelWriter outputStream = HTTPUtilResponse.openHTTPPayload(ebh, output, activeChannelId, activeSequenceNo); HTTPUtilResponse.closePayloadAndPublish(ebh, eTag(), contentType(), output, activeChannelId, activeSequenceNo, activeFieldRequestContext, outputStream, additionalHeaderWriter, 200);
HTTPUtilResponse.openToEmptyBlock(ebh, localOut); additionalHeaderWriter); HTTPUtilResponse.finalizeLengthOfFirstBlock(ebh, localOut);
HTTPUtilResponse.holdEmptyBlock(msgCommandChannel.data, connectionId, sequenceNo, pipe);
ChannelWriter outputStream = HTTPUtilResponse.openHTTPPayload(ebh, output, activeChannelId, activeSequenceNo); HTTPUtilResponse.closePayloadAndPublish( ebh, null, null, output, activeChannelId, activeSequenceNo,
HTTPUtilResponse.holdEmptyBlock(msgCommandChannel.data, connectionId, sequenceNo, pipe);
HTTPUtilResponse.holdEmptyBlock(msgCommandChannel.data, connectionId, sequenceNo, pipe);