// Path: src/org/nikki/http/content/ContentHandler.java
// public interface ContentHandler {
// 
// 	/**
// 	 * Handle a request
// 	 * 
// 	 * @param session
// 	 *            The session which initiated the request
// 	 * @return The response, or null
// 	 */
// 	public void handleRequest(HttpSession session) throws HttpResponseException;
// }
// 
// Path: src/org/nikki/http/content/HttpResponseException.java
// public class HttpResponseException extends Exception {
// 
// 	/**
// 	 * The serial uid
// 	 */
// 	private static final long serialVersionUID = -548587047264963177L;
// 
// 	/**
// 	 * The status
// 	 */
// 	private HttpResponseStatus status;
// 
// 	/**
// 	 * Construct a new exception
// 	 * 
// 	 * @param status
// 	 *            The HTTP Status to return
// 	 */
// 	public HttpResponseException(HttpResponseStatus status) {
// 		this.status = status;
// 	}
// 
// 	/**
// 	 * Get the status
// 	 * 
// 	 * @return The HTTP Status
// 	 */
// 	public HttpResponseStatus getStatus() {
// 		return status;
// 	}
// }
// 
// Path: src/org/nikki/http/net/HttpSession.java
// public class HttpSession {
// 
// 	/**
// 	 * The server instance
// 	 */
// 	private HttpServer server;
// 
// 	/**
// 	 * The Virtual Host this session is requesting by
// 	 */
// 	private VirtualHost virtualHost;
// 
// 	/**
// 	 * The request object
// 	 */
// 	private HttpRequest request;
// 
// 	/**
// 	 * The request's channel
// 	 */
// 	private Channel channel;
// 
// 	/**
// 	 * Creates an HTTP Session.
// 	 */
// 	public HttpSession(HttpServer server) {
// 		this.server = server;
// 	}
// 
// 	/**
// 	 * Get the channel
// 	 * 
// 	 * @return The session's channel
// 	 */
// 	public Channel getChannel() {
// 		return channel;
// 	}
// 
// 	/**
// 	 * Get the HTTP Request
// 	 * 
// 	 * @return The request
// 	 */
// 	public HttpRequest getRequest() {
// 		return request;
// 	}
// 
// 	/**
// 	 * Get the server this session belongs to
// 	 * 
// 	 * @return The server
// 	 */
// 	public HttpServer getServer() {
// 		return server;
// 	}
// 
// 	/**
// 	 * Handle the request
// 	 * 
// 	 * @param ctx
// 	 *            The ChannelHandlerContext of the connectino
// 	 * @param request
// 	 *            The HTTP Request
// 	 */
// 	public void handleRequest(ChannelHandlerContext ctx, HttpRequest request) {
// 		this.request = request;
// 		this.channel = ctx.getChannel();
// 
// 		server.handleRequest(this);
// 	}
// 
// 	/**
// 	 * Sends the http response.
// 	 * 
// 	 * @param res
// 	 *            The http response.
// 	 */
// 	public void sendHttpResponse(HttpResponse res) {
// 		sendHttpResponse(res, true);
// 	}
// 
// 	/**
// 	 * Sends an HTTP Response with a flag whether to close or keep alive
// 	 * 
// 	 * @param res
// 	 *            The response
// 	 * @param close
// 	 *            The flag
// 	 */
// 	public void sendHttpResponse(HttpResponse res, boolean close) {
// 		if (!res.containsHeader("Server")) {
// 			res.setHeader("Server", HttpServer.SERVER_SOFTWARE + " "
// 					+ HttpServer.SERVER_VERSION);
// 		}
// 		ChannelFuture future = channel.write(res);
// 		if (close) {
// 			future.addListener(ChannelFutureListener.CLOSE);
// 		}
// 	}
// 
// 	public void setVirtualHost(VirtualHost virtualHost) {
// 		this.virtualHost = virtualHost;
// 	}
// 
// 	public VirtualHost getVirtualHost() {
// 		return virtualHost;
// 	}
// }


import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.nikki.http.content.ContentHandler;
import org.nikki.http.content.HttpResponseException;
import org.nikki.http.net.HttpSession;
/**
 * JavaHttpd, the flexible Java webserver
 * Copyright (C) 2012 Nikki <nikki@nikkii.us>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.nikki.http.fastcgi;


/**
 * A ContentHandler for FastCGI Requests
 * 
 * @author Nikki
 * 
 */
public class FastCGIContentHandler implements ContentHandler {

	/**
	 * The FastCGI Module
	 */
	private FastCGIModule module;

	/**
	 * Construct a new ContentHandler which is set to have the server ignore the
	 * first response, since the handler will respond with the finished request
	 * 
	 * @param module
	 *            The module
	 */
	public FastCGIContentHandler(FastCGIModule module) {
		this.module = module;
	}

	@Override
// Path: src/org/nikki/http/content/ContentHandler.java
// public interface ContentHandler {
// 
// 	/**
// 	 * Handle a request
// 	 * 
// 	 * @param session
// 	 *            The session which initiated the request
// 	 * @return The response, or null
// 	 */
// 	public void handleRequest(HttpSession session) throws HttpResponseException;
// }
// 
// Path: src/org/nikki/http/content/HttpResponseException.java
// public class HttpResponseException extends Exception {
// 
// 	/**
// 	 * The serial uid
// 	 */
// 	private static final long serialVersionUID = -548587047264963177L;
// 
// 	/**
// 	 * The status
// 	 */
// 	private HttpResponseStatus status;
// 
// 	/**
// 	 * Construct a new exception
// 	 * 
// 	 * @param status
// 	 *            The HTTP Status to return
// 	 */
// 	public HttpResponseException(HttpResponseStatus status) {
// 		this.status = status;
// 	}
// 
// 	/**
// 	 * Get the status
// 	 * 
// 	 * @return The HTTP Status
// 	 */
// 	public HttpResponseStatus getStatus() {
// 		return status;
// 	}
// }
// 
// Path: src/org/nikki/http/net/HttpSession.java
// public class HttpSession {
// 
// 	/**
// 	 * The server instance
// 	 */
// 	private HttpServer server;
// 
// 	/**
// 	 * The Virtual Host this session is requesting by
// 	 */
// 	private VirtualHost virtualHost;
// 
// 	/**
// 	 * The request object
// 	 */
// 	private HttpRequest request;
// 
// 	/**
// 	 * The request's channel
// 	 */
// 	private Channel channel;
// 
// 	/**
// 	 * Creates an HTTP Session.
// 	 */
// 	public HttpSession(HttpServer server) {
// 		this.server = server;
// 	}
// 
// 	/**
// 	 * Get the channel
// 	 * 
// 	 * @return The session's channel
// 	 */
// 	public Channel getChannel() {
// 		return channel;
// 	}
// 
// 	/**
// 	 * Get the HTTP Request
// 	 * 
// 	 * @return The request
// 	 */
// 	public HttpRequest getRequest() {
// 		return request;
// 	}
// 
// 	/**
// 	 * Get the server this session belongs to
// 	 * 
// 	 * @return The server
// 	 */
// 	public HttpServer getServer() {
// 		return server;
// 	}
// 
// 	/**
// 	 * Handle the request
// 	 * 
// 	 * @param ctx
// 	 *            The ChannelHandlerContext of the connectino
// 	 * @param request
// 	 *            The HTTP Request
// 	 */
// 	public void handleRequest(ChannelHandlerContext ctx, HttpRequest request) {
// 		this.request = request;
// 		this.channel = ctx.getChannel();
// 
// 		server.handleRequest(this);
// 	}
// 
// 	/**
// 	 * Sends the http response.
// 	 * 
// 	 * @param res
// 	 *            The http response.
// 	 */
// 	public void sendHttpResponse(HttpResponse res) {
// 		sendHttpResponse(res, true);
// 	}
// 
// 	/**
// 	 * Sends an HTTP Response with a flag whether to close or keep alive
// 	 * 
// 	 * @param res
// 	 *            The response
// 	 * @param close
// 	 *            The flag
// 	 */
// 	public void sendHttpResponse(HttpResponse res, boolean close) {
// 		if (!res.containsHeader("Server")) {
// 			res.setHeader("Server", HttpServer.SERVER_SOFTWARE + " "
// 					+ HttpServer.SERVER_VERSION);
// 		}
// 		ChannelFuture future = channel.write(res);
// 		if (close) {
// 			future.addListener(ChannelFutureListener.CLOSE);
// 		}
// 	}
// 
// 	public void setVirtualHost(VirtualHost virtualHost) {
// 		this.virtualHost = virtualHost;
// 	}
// 
// 	public VirtualHost getVirtualHost() {
// 		return virtualHost;
// 	}
// }


// Path: src/org/nikki/http/fastcgi/FastCGIContentHandler.java
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.nikki.http.content.ContentHandler;
import org.nikki.http.content.HttpResponseException;
import org.nikki.http.net.HttpSession;

/**
 * JavaHttpd, the flexible Java webserver
 * Copyright (C) 2012 Nikki <nikki@nikkii.us>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.nikki.http.fastcgi;


/**
 * A ContentHandler for FastCGI Requests
 * 
 * @author Nikki
 * 
 */
public class FastCGIContentHandler implements ContentHandler {

	/**
	 * The FastCGI Module
	 */
	private FastCGIModule module;

	/**
	 * Construct a new ContentHandler which is set to have the server ignore the
	 * first response, since the handler will respond with the finished request
	 * 
	 * @param module
	 *            The module
	 */
	public FastCGIContentHandler(FastCGIModule module) {
		this.module = module;
	}

	@Override
	public void handleRequest(HttpSession session) throws HttpResponseException {