com.applitools.connectivity.api.ResponseImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eyes-connectivity-java3-jboss Show documentation
Show all versions of eyes-connectivity-java3-jboss Show documentation
Applitools Eyes SDK REST API communication implementation based on JBoss RestEasy
package com.applitools.connectivity.api;
import com.applitools.eyes.Logger;
import com.applitools.utils.ArgumentGuard;
import javax.ws.rs.core.MultivaluedMap;
import java.util.HashMap;
import java.util.Map;
public class ResponseImpl extends Response {
javax.ws.rs.core.Response response;
ResponseImpl(javax.ws.rs.core.Response response, Logger logger) {
super(logger);
this.response = response;
readEntity();
logIfError();
}
@Override
public int getStatusCode() {
return response.getStatus();
}
@Override
public String getStatusPhrase() {
return response.getStatusInfo().getReasonPhrase();
}
@Override
public String getHeader(String name, boolean ignoreCase) {
ArgumentGuard.notNullOrEmpty(name, "name");
MultivaluedMap headers = response.getStringHeaders();
if (!ignoreCase) {
return headers.getFirst(name);
}
for (String key : headers.keySet()) {
if (name.equalsIgnoreCase(key)) {
return headers.getFirst(key);
}
}
return null;
}
@Override
protected Map getHeaders() {
Map headers = new HashMap<>();
for (String key : response.getStringHeaders().keySet()) {
headers.put(key, getHeader(key, false));
}
return headers;
}
@Override
public void readEntity() {
body = response.readEntity(byte[].class);
}
@Override
public void close() {
response.close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy