use of org.parosproxy.paros.network.HttpResponseHeader in project zaproxy by zaproxy.
the class ProxyThread method setErrorResponse.
private static void setErrorResponse(HttpMessage msg, String responseStatus, String message) throws HttpMalformedHeaderException {
HttpResponseHeader responseHeader = new HttpResponseHeader("HTTP/1.1 " + responseStatus);
responseHeader.setHeader(HttpHeader.CONTENT_TYPE, "text/plain; charset=UTF-8");
responseHeader.setHeader(HttpHeader.CONTENT_LENGTH, Integer.toString(message.getBytes(StandardCharsets.UTF_8).length));
msg.setResponseHeader(responseHeader);
if (!HttpRequestHeader.HEAD.equals(msg.getRequestHeader().getMethod())) {
msg.setResponseBody(message);
}
}
use of org.parosproxy.paros.network.HttpResponseHeader in project zaproxy by zaproxy.
the class SpiderScan method readURI.
@Override
public void readURI(HttpMessage msg) {
HttpRequestHeader requestHeader = msg.getRequestHeader();
HttpResponseHeader responseHeader = msg.getResponseHeader();
resourcesFound.add(new SpiderResource(msg.getHistoryRef().getHistoryId(), requestHeader.getMethod(), requestHeader.getURI().toString(), responseHeader.getStatusCode(), responseHeader.getReasonPhrase()));
if (View.isInitialised()) {
addMessageToMessagesTableModel(msg);
}
}
use of org.parosproxy.paros.network.HttpResponseHeader in project zaproxy by zaproxy.
the class BasicAuthorizationDetectionMethodUnitTest method setUp.
@Before
public void setUp() throws Exception {
message = Mockito.mock(HttpMessage.class);
HttpResponseHeader mockedHeader = Mockito.mock(HttpResponseHeader.class);
HttpResponseBody mockedBody = Mockito.mock(HttpResponseBody.class);
Mockito.when(message.getResponseHeader()).thenReturn(mockedHeader);
Mockito.when(message.getResponseBody()).thenReturn(mockedBody);
Mockito.when(mockedBody.toString()).thenReturn(RESPONSE_BODY);
Mockito.when(mockedHeader.getStatusCode()).thenReturn(STATUS_CODE);
Mockito.when(mockedHeader.toString()).thenReturn(RESPONSE_HEADER);
}
use of org.parosproxy.paros.network.HttpResponseHeader in project zaproxy by zaproxy.
the class HttpBreakpointManagementDaemonImplUnitTest method shouldBreakOnAllHttpRequestsAndResponses.
@Test
public void shouldBreakOnAllHttpRequestsAndResponses() throws HttpMalformedHeaderException {
impl.setBreakAll(true);
HttpMessage msg = new HttpMessage();
assertTrue(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 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));
}
Aggregations