<commit_before>package com.ociweb.gl.api;

import com.ociweb.gl.impl.schema.TrafficOrderSchema;
import com.ociweb.pronghorn.network.HTTPUtilResponse;
import com.ociweb.pronghorn.network.OrderSupervisorStage;
import com.ociweb.pronghorn.network.ServerCoordinator;
import com.ociweb.pronghorn.network.config.HTTPContentType;
import com.ociweb.pronghorn.network.config.HTTPHeaderDefaults;
import com.ociweb.pronghorn.network.config.HTTPRevisionDefaults;
import com.ociweb.pronghorn.network.http.HTTPResponseStatusCodes;
import com.ociweb.pronghorn.network.http.HTTPUtil;
import com.ociweb.pronghorn.network.http.HeaderWritable;
import com.ociweb.pronghorn.network.http.HeaderWriter;
import com.ociweb.pronghorn.network.http.SequenceValidator;
import com.ociweb.pronghorn.network.schema.ServerResponseSchema;
import com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager;
import com.ociweb.pronghorn.pipe.Pipe;
import com.ociweb.pronghorn.pipe.PipeConfig;
import com.ociweb.pronghorn.util.Appendables;

public class HTTPResponseService {

	private static final int TWO_RESPONSE_BLOCKS_SIZE = 2*Pipe.sizeOf(ServerResponseSchema.instance, ServerResponseSchema.MSG_TOCHANNEL_100);
	private final MsgCommandChannel<?> msgCommandChannel;
	public static final byte[] SERVER_HEADER_NAME = "GreenLightning".getBytes();
	private static final int minHeader = 128;
	private transient SequenceValidator validator; //will be null unless assertions are on.
	private final int maxGoFragmentSize;
	private final int maxNetRespFragmentSize;
	
	
	private boolean setupValidator() {
		validator = new SequenceValidator();
		return true;
	}
	
	public HTTPResponseService(MsgCommandChannel<?> msgCommandChannel) {
		this.msgCommandChannel = msgCommandChannel;
		msgCommandChannel.initFeatures |= MsgCommandChannel.NET_RESPONDER;		
		msgCommandChannel.pcm.ensureSize(ServerResponseSchema.class, 1, minHeader);
		assert(setupValidator());
						 
		maxGoFragmentSize = FieldReferenceOffsetManager.maxFragmentSize(Pipe.from(msgCommandChannel.goPipe));
		maxNetRespFragmentSize = FieldReferenceOffsetManager.maxFragmentSize(Pipe.from(msgCommandChannel.netResponse[0]));
	}

	/**
	 *	<commit_msg>fixed null pointer<commit_after>package com.ociweb.gl.api;

import com.ociweb.gl.impl.schema.TrafficOrderSchema;
import com.ociweb.pronghorn.network.HTTPUtilResponse;
import com.ociweb.pronghorn.network.OrderSupervisorStage;
import com.ociweb.pronghorn.network.ServerCoordinator;
import com.ociweb.pronghorn.network.config.HTTPContentType;
import com.ociweb.pronghorn.network.config.HTTPHeaderDefaults;
import com.ociweb.pronghorn.network.config.HTTPRevisionDefaults;
import com.ociweb.pronghorn.network.http.HTTPResponseStatusCodes;
import com.ociweb.pronghorn.network.http.HTTPUtil;
import com.ociweb.pronghorn.network.http.HeaderWritable;
import com.ociweb.pronghorn.network.http.HeaderWriter;
import com.ociweb.pronghorn.network.http.SequenceValidator;
import com.ociweb.pronghorn.network.schema.ServerResponseSchema;
import com.ociweb.pronghorn.pipe.FieldReferenceOffsetManager;
import com.ociweb.pronghorn.pipe.Pipe;
import com.ociweb.pronghorn.pipe.PipeConfig;
import com.ociweb.pronghorn.util.Appendables;

public class HTTPResponseService {

	private static final int TWO_RESPONSE_BLOCKS_SIZE = 2*Pipe.sizeOf(ServerResponseSchema.instance, ServerResponseSchema.MSG_TOCHANNEL_100);
	private final MsgCommandChannel<?> msgCommandChannel;
	public static final byte[] SERVER_HEADER_NAME = "GreenLightning".getBytes();
	private static final int minHeader = 128;
	private transient SequenceValidator validator; //will be null unless assertions are on.
	private final int maxGoFragmentSize;
	private final int maxNetRespFragmentSize;
	
	
	private boolean setupValidator() {
		validator = new SequenceValidator();
		return true;
	}
	
	public HTTPResponseService(MsgCommandChannel<?> msgCommandChannel) {
		this.msgCommandChannel = msgCommandChannel;
		msgCommandChannel.initFeatures |= MsgCommandChannel.NET_RESPONDER;		
		msgCommandChannel.pcm.ensureSize(ServerResponseSchema.class, 1, minHeader);
		assert(setupValidator());
						 
		maxGoFragmentSize = FieldReferenceOffsetManager.maxFragmentSize(TrafficOrderSchema.FROM);
		maxNetRespFragmentSize = FieldReferenceOffsetManager.maxFragmentSize(ServerResponseSchema.FROM);
	}

	/**
	 *	
{'fraction_non_alphanumeric': 0.08826945412311266, 'fraction_numerical': 0.003948896631823461, 'mean_word_length': 6.959334565619224, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1117385', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1280, 'n_words': 210}