org.mockserver.model.HttpResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockserver-core Show documentation
Show all versions of mockserver-core Show documentation
Functionality used by all MockServer modules for matching and expectations
package org.mockserver.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @author jamesdbloom
*/
public class HttpResponse extends ModelObject {
private Integer statusCode = 200;
private String body = "";
private List cookies = new ArrayList();
private List headers = new ArrayList();
private Delay delay = new Delay(TimeUnit.MICROSECONDS, 0);
public HttpResponse() {
}
public HttpResponse withStatusCode(Integer statusCode) {
this.statusCode = statusCode;
return this;
}
public Integer getStatusCode() {
return statusCode;
}
public HttpResponse withBody(String body) {
this.body = body;
return this;
}
public String getBody() {
return body;
}
public HttpResponse withCookies(List cookies) {
this.cookies = cookies;
return this;
}
public HttpResponse withCookies(Cookie... cookies) {
this.cookies = Arrays.asList(cookies);
return this;
}
public List getCookies() {
return cookies;
}
public HttpResponse withHeaders(List headers) {
this.headers = headers;
return this;
}
public HttpResponse withHeaders(Header... headers) {
this.headers = Arrays.asList(headers);
return this;
}
public List getHeaders() {
return headers;
}
public HttpResponse withDelay(Delay delay) {
this.delay = delay;
return this;
}
public Delay getDelay() {
return delay;
}
public HttpResponse applyDelay() {
if (delay != null) {
delay.applyDelay();
}
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy