package io.vertx.ext.auth.impl.http;
import io.vertx.codegen.annotations.Nullable;
import io.vertx.core.MultiMap;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
public final class SimpleHttpResponse {
private final int statusCode;
private final MultiMap ;
private final Buffer body;
public SimpleHttpResponse(int statusCode, MultiMap headers, Buffer body) {
this.headers = headers;
this.body = body;
this.statusCode = statusCode;
}
public int statusCode() {
return statusCode;
}
public MultiMap () {
return headers;
}
public String (String header) {
if (headers != null) {
return headers.get(header);
}
return null;
}
public Buffer body() {
return body;
}
public @Nullable JsonObject jsonObject() {
return new JsonObject(body);
}
public @Nullable JsonArray jsonArray() {
return new JsonArray(body);
}
public boolean is(String contentType) {
if (headers != null) {
String header = headers.get("Content-Type");
if (header != null) {
int sep = header.indexOf(';');
if (sep != -1) {
header = header.substring(0, sep).trim();
}
return contentType.equalsIgnoreCase(header);
}
}
return false;
}
}