Skip to content

A free, open-source alternative to Burp Suite: an intercepting proxy and web app security testing suite with Repeater, Intruder, Collaborator and a built-in OWASP ZAP scanner. Linux, AGPL-3.0.

1.2 KB
Raw Blame
package opensuite.script.api;

import java.util.List;

import opensuite.core.HttpMessage;

/** A response as a script sees it: read only, over a copy of the shown response. */
public final class HttpResponse {

    private final HttpMessage message;

    private HttpResponse(HttpMessage message) { this.message = message; }

    /** A response over a copy of {@code m}. */
    public static HttpResponse of(HttpMessage m) {
        return new HttpResponse(m == null ? new HttpMessage(new byte[0]) : m.copy());
    }

    public int statusCode() { return message.statusCode(); }

    /** The first header with this name (any case), or null. */
    public String header(String name) { return message.header(name); }

    /** The header lines, without the status line. */
    public List<String> headers() { return Messages.headers(message); }

    /** The body's exact bytes. */
    public byte[] body() { return message.body(); }

    /** The body as text, in the declared charset or else UTF-8. */
    public String bodyText() { return Messages.bodyText(message); }

    /** The body's type in the history's terms, such as "json" or "html". */
    public String mimeType() { return message.mimeType(); }
}