* @see
* org.parosproxy.paros.extension.filter.FilterAdaptor#onHttpResponseReceive
* (org.parosproxy.paros.network.HttpMessage)
*/
public void onHttpResponseReceive(HttpMessage msg) {
HttpResponseHeader resHeader = msg.getResponseHeader();
if (resHeader == null || resHeader.isEmpty()) {
return;
}
if (resHeader.getHeader("Set-cookie") != null) {
String content = resHeader.toString();
matcher = pattern.matcher(content);
result = new Vector<String>();
while (matcher.find()) {
String cookie = matcher.group(1);
if (cookie != null) {
// Modal dialog with OK/cancel and a text field
getView().getMainFrame().toFront();
String text = JOptionPane
.showInputDialog(
getView().getMainFrame(),
"Accept the following cookie (Ok=Accept, Cancel=Reject)?",
cookie);
// text == null means cancel pressed. If cancel, cookie
// rejected
if ((text != null && !text.equals(""))) {
resHeader.setHeader("Set-cookie", null);
result.add(text);
} else if (text == null) {
resHeader.setHeader("Set-cookie", null);
}
}
}
if (result.size() > 0) {
content = matcher.replaceAll("");
for (int i = 0; i < result.size(); i++) {
content += "Set-Cookie: " + result.get(i).toString()
+ "\r\n";
}
try {
// resHeader = new HttpResponseHeader(content);
resHeader.setMessage(content);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}