<commit_before>/**
 * Project pack:tag >> http://packtag.sf.net
 *
 * This software is published under the terms of the LGPL
 * License version 2.1, a copy of which has been included with this
 * distribution in the 'lgpl.txt' file.
 * 
 * Last author:   $Author: danielgalan $
 * Last modified: $Date: 2008/03/15 17:21:11 $
 * Revision:      $Revision: 1.10 $
 * 
 * $Log: PackServlet.java,v $
 * Revision 1.10  2008/03/15 17:21:11  danielgalan
 * more Header externalized
 *
 * Revision 1.9  2008/03/15 16:38:31  danielgalan
 * Header / request cleaning
 *
 * Revision 1.8  2007/11/12 22:57:24  danielgalan
 * renamed sqp to absolutePath and fqp to mappedPath
 *
 * Revision 1.7  2007/11/06 23:10:25  danielgalan
 * Switch to new URI-semantic
 *
 * Revision 1.6  2007/10/13 20:20:22  danielgalan
 * added "Content-Type" header for MIME-Type and charset (UTF-8)
 *
 * Revision 1.5  2007/09/29 21:22:27  danielgalan
 * evaluate "If-None-Match" header
 *
 * Revision 1.4  2007/08/27 22:37:29  danielgalan
 * expire date now ten years in the future (that should be enough ;))
 *
 * Revision 1.3  2007/07/12 22:10:40  danielgalan
 * removed system.out
 *
 * Revision 1.2  2007/07/11 23:01:30  danielgalan
 * - 2.2
 *   - enhancement: caching header improved (servlet)
 *   - servlet url-mapping can be changed now (you have to set "packtag.cache.servlet.path" to the same value)
 *   - enhancement: polished the reference at http://www.galan.de/projects/packtag
 *
 * Revision 1.1  2007/04/22 19:04:25  danielgalan
 * pack.tag moved from subversion to good old CVS
 *
 */
package net.sf.packtag.servlet;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.packtag.cache.PackCache;
import net.sf.packtag.cache.Resource;
import net.sf.packtag.util.HttpHeader;
import net.sf.packtag.util.RequestUtil;



/**
 * Servlet implementation class for Servlet: PackServlet
 * This Servlet return the packed resources, identified thru the mapped path (and hashcode).
 * Only needed when Servlet is choosen as cachetype (default).
 * The output is gzip-compressed.
 * 
 * @author <NAME>
 * @version $Revision: 1.10 $
 */
public class PackServlet extends HttpServlet {

	private static final long serialVersionUID = 6588877416667767264L;

	private static final long ONE_YEAR = 31536000000L;
	private static final long TEN_YEARS = ONE_YEAR * 10L;
	private static final String ETAG_PREFIX = "pack";

	private static final String CONTENT_TYPE = "Content-Type";
	private static final String CHARSET_UTF8 = ";charset=utf-8";


	protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
		Resource resource = PackCache.getResourceByMappedPath(request.getRequestURI());

		if (resource == null) {
			response.setStatus(404);
		}
		else {
			setHeaders(response, resource);

			if (isNotModifed(request, resource)) {
				response.setStatus(304);
			}
			else {
				writeResource(request, response, resource);
			}
		}<commit_msg>Give the 404 a more meaningfull message<commit_after>/**
 * Project pack:tag >> http://packtag.sf.net
 *
 * This software is published under the terms of the LGPL
 * License version 2.1, a copy of which has been included with this
 * distribution in the 'lgpl.txt' file.
 * 
 * Last author:   $Author: danielgalan $
 * Last modified: $Date: 2008/03/15 17:21:11 $
 * Revision:      $Revision: 1.10 $
 * 
 * $Log: PackServlet.java,v $
 * Revision 1.10  2008/03/15 17:21:11  danielgalan
 * more Header externalized
 *
 * Revision 1.9  2008/03/15 16:38:31  danielgalan
 * Header / request cleaning
 *
 * Revision 1.8  2007/11/12 22:57:24  danielgalan
 * renamed sqp to absolutePath and fqp to mappedPath
 *
 * Revision 1.7  2007/11/06 23:10:25  danielgalan
 * Switch to new URI-semantic
 *
 * Revision 1.6  2007/10/13 20:20:22  danielgalan
 * added "Content-Type" header for MIME-Type and charset (UTF-8)
 *
 * Revision 1.5  2007/09/29 21:22:27  danielgalan
 * evaluate "If-None-Match" header
 *
 * Revision 1.4  2007/08/27 22:37:29  danielgalan
 * expire date now ten years in the future (that should be enough ;))
 *
 * Revision 1.3  2007/07/12 22:10:40  danielgalan
 * removed system.out
 *
 * Revision 1.2  2007/07/11 23:01:30  danielgalan
 * - 2.2
 *   - enhancement: caching header improved (servlet)
 *   - servlet url-mapping can be changed now (you have to set "packtag.cache.servlet.path" to the same value)
 *   - enhancement: polished the reference at http://www.galan.de/projects/packtag
 *
 * Revision 1.1  2007/04/22 19:04:25  danielgalan
 * pack.tag moved from subversion to good old CVS
 *
 */
package net.sf.packtag.servlet;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.packtag.cache.PackCache;
import net.sf.packtag.cache.Resource;
import net.sf.packtag.util.HttpHeader;
import net.sf.packtag.util.RequestUtil;



/**
 * Servlet implementation class for Servlet: PackServlet
 * This Servlet return the packed resources, identified thru the mapped path (and hashcode).
 * Only needed when Servlet is choosen as cachetype (default).
 * The output is gzip-compressed.
 * 
 * @author <NAME>
 * @version $Revision: 1.10 $
 */
public class PackServlet extends HttpServlet {

	private static final long serialVersionUID = 6588877416667767264L;

	private static final long ONE_YEAR = 31536000000L;
	private static final long TEN_YEARS = ONE_YEAR * 10L;
	private static final String ETAG_PREFIX = "pack";

	private static final String CONTENT_TYPE = "Content-Type";
	private static final String CHARSET_UTF8 = ";charset=utf-8";


	protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
		Resource resource = PackCache.getResourceByMappedPath(request.getRequestURI());

		if (resource == null) {
			response.sendError(404, "The requested packed resource was not found.");
		}
		else {
			setHeaders(response, resource);

			if (isNotModifed(request, resource)) {
				response.setStatus(304);
			}
			else {
				writeResource(request, response, resource);
			}
		}
{'fraction_non_alphanumeric': 0.1028125, 'fraction_numerical': 0.07109375, 'mean_word_length': 3.8974751338944147, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1694013', 'n_tokens_mistral': 2429, 'n_tokens_neox': 2047, 'n_words': 619}