<commit_before>package com.google.code.kaptcha.servlet;

import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;

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

import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
import com.google.code.kaptcha.util.Helper;


/**
 * This servlet uses the settings passed into it via the 
 * Producer api.
 * 
 * @author		<EMAIL>
 */
@SuppressWarnings("serial")
public class KaptchaServlet extends HttpServlet implements Servlet
{	
	private Properties props = new Properties();

	private Producer captchaProducer = null;

	public void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException
	{

		resp.setHeader("Pragma", "no-cache");
		resp.setHeader("Cache-Control", "no-cache");

		// this key can be read from any controller to check whether user
		// is a computer or human..
		String capText = captchaProducer.createText();
		req.getSession().setAttribute(Constants.KAPTCHA_SESSION_KEY, capText);

		// notice we don't store the captext in the producer. This is because
		// the thing is not thread safe and we do use the producer as an instance
		// variable in the servlet.
		captchaProducer.createImage(resp.getOutputStream(), capText);
	}

	/* (non-Javadoc)
	 * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
	 */
	public void init(ServletConfig conf) throws ServletException
	{
		super.init(conf);

		Enumeration<?> initParams = conf.getInitParameterNames();
		while (initParams.hasMoreElements())
		{
			String key = (String)initParams.nextElement();
			String value = conf.getInitParameter(key);
			props.put(key, value);
		}
		
		this.captchaProducer = (Producer) Helper.ThingFactory.loadImpl(Helper.ThingFactory.PRODUCER_IMPL, props);
	}
}
<commit_msg>added in response headers for no caching and a missing content type.<commit_after>package com.google.code.kaptcha.servlet;

import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;

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

import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
import com.google.code.kaptcha.util.Helper;


/**
 * This servlet uses the settings passed into it via the 
 * Producer api.
 * 
 * @author		<EMAIL>
 */
@SuppressWarnings("serial")
public class KaptchaServlet extends HttpServlet implements Servlet
{	
	private Properties props = new Properties();

	private Producer captchaProducer = null;

	public void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException
	{

		resp.setHeader("Pragma", "no-cache");
		resp.setHeader("Cache-Control", "no-cache, no-store");
		resp.setDateHeader("Expires", 0);
		resp.setContentType("image/jpeg");

		// this key can be read from any controller to check whether user
		// is a computer or human..
		String capText = captchaProducer.createText();
		req.getSession().setAttribute(Constants.KAPTCHA_SESSION_KEY, capText);

		// notice we don't store the captext in the producer. This is because
		// the thing is not thread safe and we do use the producer as an instance
		// variable in the servlet.
		captchaProducer.createImage(resp.getOutputStream(), capText);
	}

	/* (non-Javadoc)
	 * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
	 */
	public void init(ServletConfig conf) throws ServletException
	{
		super.init(conf);

		Enumeration<?> initParams = conf.getInitParameterNames();
		while (initParams.hasMoreElements())
		{
			String key = (String)initParams.nextElement();
			String value = conf.getInitParameter(key);
			props.put(key, value);
		}
		
		this.captchaProducer = (Producer) Helper.ThingFactory.loadImpl(Helper.ThingFactory.PRODUCER_IMPL, props);
	}
}

{'fraction_non_alphanumeric': 0.10631629701060752, 'fraction_numerical': 0.00024108003857280618, 'mean_word_length': 4.802797202797203, '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': '6985753', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1232, 'n_words': 319}