fix image type

This commit is contained in:
Pablo 2010-11-24 00:32:13 +01:00
parent dfba30f83f
commit f63fcae531

View File

@ -46,9 +46,10 @@ public class CaptchaController
throws Exception throws Exception
{ {
byte[] captchaChallengeAsJpeg; response.setHeader("Cache-Control", "no-store");
// the output stream to render the captcha image as jpeg into response.setHeader("Pragma", "no-cache");
final ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream(); response.setDateHeader("Expires", 0);
response.setContentType("image/png");
// get the session id that will identify the generated captcha. // get the session id that will identify the generated captcha.
//the same id must be used to validate the response, the session id is a good candidate! //the same id must be used to validate the response, the session id is a good candidate!
@ -58,10 +59,6 @@ public class CaptchaController
final BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale()); final BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale());
// flush it in the response // flush it in the response
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("image/jpeg");
final ServletOutputStream responseOutputStream = response.getOutputStream(); final ServletOutputStream responseOutputStream = response.getOutputStream();
ImageIO.write(challenge, "png", responseOutputStream); ImageIO.write(challenge, "png", responseOutputStream);
responseOutputStream.flush(); responseOutputStream.flush();