private int echoHeaders(DataOutputBlobWriter<NetPayloadSchema> outputStream, int len, final int blobMask,
byte[] blob, final int bytePosition, ChannelReader reader) {
HTTPHeader[] headersToEcho = conStruct.headersToEcho();
if (null!=headersToEcho) {
int newLinePos = (bytePosition+len-2);
assert(blob[newLinePos&blobMask]=='\r');
assert(blob[(1+newLinePos)&blobMask]=='\n');
if (blob[newLinePos&blobMask]=='\r') {
len-=2;
DataOutputBlobWriter.write(outputStream, blob, bytePosition, len, blobMask);
len = 0;
for(int i=0; i<headersToEcho.length; i++) {
HTTPHeader header = headersToEcho[i];
if (!reader.structured().isNull(header)) {
System.err.println("echo header "+header);
spec.writeHeader(outputStream, header, reader.structured().read(header));
}
}
outputStream.write(BYTES_NEWLINE);
}
}
return len;
}