package com.jscape.inet.http.protocol.messages;

import java.io.InputStream;
import java.util.Arrays;

import static com.jscape.util.Parameters.assertNotNull;

/**
 * @author Alex Usun
 */
public class ResponseMessage
        extends Message {

    public final String protocolVersion;
    public final int statusCode;
    public final String reasonPhrase;
    public final Header[] headers;
    public final InputStream body;

    public ResponseMessage(String protocolVersion, int statusCode, String reasonPhrase, Header[] headers, InputStream body) {
        assertNotNull(protocolVersion);
        this.protocolVersion = protocolVersion;

        this.statusCode = statusCode;

        assertNotNull(reasonPhrase);
        this.reasonPhrase = reasonPhrase;

        assertNotNull(headers);
        this.headers = headers;

        assertNotNull(body);
        this.body = body;
    }

    @Override
    public String toString() {
        return "Response {"
               + "protocolVersion='" + this.protocolVersion + '\''
               + ", statusCode=" + this.statusCode
               + ", reasonPhrase='" + this.reasonPhrase + '\''
               + ", headers=" + Arrays.toString(this.headers)
               + ", body=" + this.body
               + '}';
    }
}
