// Path: src/org/nikki/http/fastcgi/FastCGIConstants.java
// public static final int FCGI_END_REQUEST = 3;
// 
// Path: src/org/nikki/http/fastcgi/FastCGIConstants.java
// public static final int FCGI_REQUEST_COMPLETE = 0;
// 
// Path: src/org/nikki/http/fastcgi/FastCGIConstants.java
// public static final int FCGI_STDERR = 7;
// 
// Path: src/org/nikki/http/fastcgi/FastCGIConstants.java
// public static final int FCGI_STDOUT = 6;
// 
// Path: src/org/nikki/http/fastcgi/FastCGIResponse.java
// public class FastCGIResponse {
// 
// 	/**
// 	 * The original request id
// 	 */
// 	private int id;
// 
// 	/**
// 	 * The completed data of the request
// 	 */
// 	private ChannelBuffer data;
// 
// 	/**
// 	 * Construct a new response
// 	 * 
// 	 * @param id
// 	 *            The request id
// 	 * @param data
// 	 *            The response
// 	 */
// 	public FastCGIResponse(int id, ChannelBuffer data) {
// 		this.id = id;
// 		this.data = data;
// 	}
// 
// 	/**
// 	 * Get the data buffer
// 	 * 
// 	 * @return The ChannelBuffer containing the response data
// 	 */
// 	public ChannelBuffer getData() {
// 		return data;
// 	}
// 
// 	/**
// 	 * Get the request id
// 	 * 
// 	 * @return The request id
// 	 */
// 	public int getId() {
// 		return id;
// 	}
// }


import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
import org.nikki.http.fastcgi.FastCGIResponse;
import static org.nikki.http.fastcgi.FastCGIConstants.FCGI_END_REQUEST;
import static org.nikki.http.fastcgi.FastCGIConstants.FCGI_REQUEST_COMPLETE;
import static org.nikki.http.fastcgi.FastCGIConstants.FCGI_STDERR;
import static org.nikki.http.fastcgi.FastCGIConstants.FCGI_STDOUT;
import java.util.HashMap;
import java.util.logging.Logger;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
				if (appStatus != 0 || protocolStatus != FCGI_REQUEST_COMPLETE) {
					// Uh oh, when we run a pool of connections we should close
					// this one here...
					logger.warning("Protocol status " + protocolStatus);
				} else if (protocolStatus == FCGI_REQUEST_COMPLETE) {
					// Reset the version
					checkpoint(ResponseState.VERSION);
					// Merged from ChannelBuffer buffer ... dataBuffers.remove
					// to this, remove() returns the object
					return new FastCGIResponse(id, dataBuffers.remove(id));
				}
				checkpoint(ResponseState.VERSION);
				break;
			case FCGI_STDOUT:
				if (contentLength > 0) {
					// Have to store it, just in case we get a new request
					if (!dataBuffers.containsKey(id)) {
						dataBuffers.put(id, ChannelBuffers.dynamicBuffer());
					}
					logger.finest("Got " + contentLength
							+ " bytes for request " + id);
					// Write the bytes to the buffer
					dataBuffers.get(id).writeBytes(
							buffer.readBytes(contentLength));
					// Checkpoint!
					checkpoint(ResponseState.VERSION);
				}
				break;
			// solaroperator pointed out this never contains HTML, I forgot a
			// checkpoint so it stayed STDERR even with 0 bytes
// Path: src/org/nikki/http/fastcgi/FastCGIConstants.java
// public static final int FCGI_END_REQUEST = 3;
// 
// Path: src/org/nikki/http/fastcgi/FastCGIConstants.java
// public static final int FCGI_REQUEST_COMPLETE = 0;
// 
// Path: src/org/nikki/http/fastcgi/FastCGIConstants.java
// public static final int FCGI_STDERR = 7;
// 
// Path: src/org/nikki/http/fastcgi/FastCGIConstants.java
// public static final int FCGI_STDOUT = 6;
// 
// Path: src/org/nikki/http/fastcgi/FastCGIResponse.java
// public class FastCGIResponse {
// 
// 	/**
// 	 * The original request id
// 	 */
// 	private int id;
// 
// 	/**
// 	 * The completed data of the request
// 	 */
// 	private ChannelBuffer data;
// 
// 	/**
// 	 * Construct a new response
// 	 * 
// 	 * @param id
// 	 *            The request id
// 	 * @param data
// 	 *            The response
// 	 */
// 	public FastCGIResponse(int id, ChannelBuffer data) {
// 		this.id = id;
// 		this.data = data;
// 	}
// 
// 	/**
// 	 * Get the data buffer
// 	 * 
// 	 * @return The ChannelBuffer containing the response data
// 	 */
// 	public ChannelBuffer getData() {
// 		return data;
// 	}
// 
// 	/**
// 	 * Get the request id
// 	 * 
// 	 * @return The request id
// 	 */
// 	public int getId() {
// 		return id;
// 	}
// }


// Path: src/org/nikki/http/fastcgi/net/FastCGIDecoder.java
import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
import org.nikki.http.fastcgi.FastCGIResponse;
import static org.nikki.http.fastcgi.FastCGIConstants.FCGI_END_REQUEST;
import static org.nikki.http.fastcgi.FastCGIConstants.FCGI_REQUEST_COMPLETE;
import static org.nikki.http.fastcgi.FastCGIConstants.FCGI_STDERR;
import static org.nikki.http.fastcgi.FastCGIConstants.FCGI_STDOUT;
import java.util.HashMap;
import java.util.logging.Logger;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;

				if (appStatus != 0 || protocolStatus != FCGI_REQUEST_COMPLETE) {
					// Uh oh, when we run a pool of connections we should close
					// this one here...
					logger.warning("Protocol status " + protocolStatus);
				} else if (protocolStatus == FCGI_REQUEST_COMPLETE) {
					// Reset the version
					checkpoint(ResponseState.VERSION);
					// Merged from ChannelBuffer buffer ... dataBuffers.remove
					// to this, remove() returns the object
					return new FastCGIResponse(id, dataBuffers.remove(id));
				}
				checkpoint(ResponseState.VERSION);
				break;
			case FCGI_STDOUT:
				if (contentLength > 0) {
					// Have to store it, just in case we get a new request
					if (!dataBuffers.containsKey(id)) {
						dataBuffers.put(id, ChannelBuffers.dynamicBuffer());
					}
					logger.finest("Got " + contentLength
							+ " bytes for request " + id);
					// Write the bytes to the buffer
					dataBuffers.get(id).writeBytes(
							buffer.readBytes(contentLength));
					// Checkpoint!
					checkpoint(ResponseState.VERSION);
				}
				break;
			// solaroperator pointed out this never contains HTML, I forgot a
			// checkpoint so it stayed STDERR even with 0 bytes
			case FCGI_STDERR: