use of org.parosproxy.paros.network.HttpResponseHeader in project zaproxy by zaproxy.
the class HttpBreakpointManagementDaemonImplUnitTest method shouldBreakOnJustHttpResponses.
@Test
public void shouldBreakOnJustHttpResponses() throws HttpMalformedHeaderException {
impl.setBreakAllResponses(true);
HttpMessage msg = new HttpMessage();
assertFalse(impl.isHoldMessage(msg));
HttpResponseHeader resHeader = new HttpResponseHeader(OK_RESPONSE);
msg.setResponseHeader(resHeader);
assertTrue(impl.isHoldMessage(msg));
}
use of org.parosproxy.paros.network.HttpResponseHeader in project zaproxy by zaproxy.
the class FilterDetectSetCookie method onHttpResponseReceive.
@Override
public void onHttpResponseReceive(HttpMessage msg) {
HttpResponseHeader resHeader = msg.getResponseHeader();
if (resHeader == null || resHeader.isEmpty()) {
return;
}
if (resHeader.getHeader("Set-cookie") != null) {
Matcher matcher = pattern.matcher(resHeader.toString());
List<String> result = new LinkedList<>();
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) {
StringBuilder sbContent = new StringBuilder(matcher.replaceAll(""));
Iterator<String> it = result.iterator();
while (it.hasNext()) {
sbContent.append("Set-Cookie: ").append(it.next()).append(CRLF);
}
try {
// resHeader = new HttpResponseHeader(content);
resHeader.setMessage(sbContent.toString());
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
}
use of org.parosproxy.paros.network.HttpResponseHeader in project zaproxy by zaproxy.
the class HttpBreakpointManagementDaemonImplUnitTest method shouldStep.
@Test
public void shouldStep() throws HttpMalformedHeaderException {
impl.setBreakAll(true);
HttpMessage msg = new HttpMessage();
assertTrue(impl.isHoldMessage(msg));
impl.step();
assertTrue(impl.isStepping());
// False the first time
assertFalse(impl.isHoldMessage(msg));
// Then true for subsequent times
assertTrue(impl.isHoldMessage(msg));
assertTrue(impl.isStepping());
HttpResponseHeader resHeader = new HttpResponseHeader(OK_RESPONSE);
msg.setResponseHeader(resHeader);
impl.step();
assertTrue(impl.isStepping());
// False the first time
assertFalse(impl.isHoldMessage(msg));
// Then true for subsequent times
assertTrue(impl.isHoldMessage(msg));
assertTrue(impl.isStepping());
}
use of org.parosproxy.paros.network.HttpResponseHeader in project zaproxy by zaproxy.
the class HttpBreakpointManagementDaemonImplUnitTest method shouldBreakOnJustHttpRequests.
@Test
public void shouldBreakOnJustHttpRequests() throws HttpMalformedHeaderException {
impl.setBreakAllRequests(true);
HttpMessage msg = new HttpMessage();
assertTrue(impl.isHoldMessage(msg));
HttpResponseHeader resHeader = new HttpResponseHeader(OK_RESPONSE);
msg.setResponseHeader(resHeader);
assertFalse(impl.isHoldMessage(msg));
}
Aggregations