public CouchHttpResponse createDatabase(String databaseName) {
try {
// Jersey does not allow for null entity on put.
Entity entity = Entity.entity("", MediaType.WILDCARD_TYPE);
WebTarget webTarget = newWebTarget(databaseName);
Response response = webTarget.request(MediaType.APPLICATION_JSON_TYPE)
.put(entity);
CouchStatusCode statusCode = CouchStatusCode.findByCode(response.getStatus());
String eTag = getETag(response);
byte[] content = response.readEntity(byte[].class);
CouchMediaType mediaType = CouchMediaType.fromString(response.getMediaType().toString());
int contentLength = response.getLength();
return CouchHttpResponse.builder(CouchMethodType.PUT, webTarget.getUri(), statusCode)
.setDocumentRevision(eTag)
.setContent(mediaType, contentLength, content)
.build();
} catch (Throwable ex) {
throw CouchHttpException.internalServerError(ex);