Groups
Groups
Sign in
Groups
Groups
Cage - Captcha Generator Java Library
Conversations
About
Send feedback
Help
Cage.draw(String, OutputStream) returns before the writting to OutputStream is actually finished
59 views
Skip to first unread message
Alex Trezvy
unread,
Nov 18, 2014, 7:04:39 PM
11/18/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cage...@googlegroups.com
Hi. I'm trying to encode the resulting image into base64 before sending it out:
String token = cage.getTokenGenerator().next();
HttpSession session = req.getSession(true);
session.setAttribute(TOKEN, token);
StringBuilder result = new StringBuilder();
result.append("<p>Please solve the puzzle: </p>");
result.append("<p>");
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
cage.draw(token, bytes);
result.append("<img alt=\"CAPTCHA\" src=\"image/jpeg;base64,\"");
result.append(Base64.encodeBase64String(bytes.toByteArray()));
result.append("\"/>");
} catch (IOException e) {
result.append("ERROR HAPPENS!");
}
result.append("<input name=\"" + ANSWER + "\"/>");
result.append("</p>");
return result.toString();
What I actually get is image stuff mixed with my HTML stuff.
It seems like there are concurrent access to the 'bytes'. No good.
Alex Trezvy
unread,
Nov 19, 2014, 8:04:56 PM
11/19/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cage...@googlegroups.com
Sorry for false alarm. My bug was due to invalid content of "src" attribute.
Reply all
Reply to author
Forward
0 new messages