Search in sources :

Example 1 with HttpResponseHeader

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);
    }
}
Also used : HttpResponseHeader(org.parosproxy.paros.network.HttpResponseHeader)

Example 2 with HttpResponseHeader

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);
    }
}
Also used : HttpResponseHeader(org.parosproxy.paros.network.HttpResponseHeader) HttpRequestHeader(org.parosproxy.paros.network.HttpRequestHeader)

Example 3 with HttpResponseHeader

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);
}
Also used : HttpResponseHeader(org.parosproxy.paros.network.HttpResponseHeader) HttpResponseBody(org.zaproxy.zap.network.HttpResponseBody) HttpMessage(org.parosproxy.paros.network.HttpMessage) Before(org.junit.Before)

Example 4 with HttpResponseHeader

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));
}
Also used : HttpResponseHeader(org.parosproxy.paros.network.HttpResponseHeader) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Example 5 with HttpResponseHeader

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));
}
Also used : HttpResponseHeader(org.parosproxy.paros.network.HttpResponseHeader) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Aggregations

HttpResponseHeader (org.parosproxy.paros.network.HttpResponseHeader)9 HttpMessage (org.parosproxy.paros.network.HttpMessage)5 Test (org.junit.Test)4 WithConfigsTest (org.zaproxy.zap.WithConfigsTest)4 HarContent (edu.umass.cs.benchlab.har.HarContent)1 HarCookie (edu.umass.cs.benchlab.har.HarCookie)1 HarCookies (edu.umass.cs.benchlab.har.HarCookies)1 HarQueryString (edu.umass.cs.benchlab.har.HarQueryString)1 HarResponse (edu.umass.cs.benchlab.har.HarResponse)1 HttpCookie (java.net.HttpCookie)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 Matcher (java.util.regex.Matcher)1 Before (org.junit.Before)1 HttpRequestHeader (org.parosproxy.paros.network.HttpRequestHeader)1 HttpResponseBody (org.zaproxy.zap.network.HttpResponseBody)1