use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicHttpResponse in project OpenRefine by OpenRefine.
the class AppEngineClientConnection method receiveResponseHeader.
public HttpResponse receiveResponseHeader() {
URLFetchService ufs = URLFetchServiceFactory.getURLFetchService();
try {
_appengine_hresponse = ufs.fetch(_appengine_hrequest);
} catch (java.io.IOException e) {
throw new RuntimeException(e);
}
org.apache.http.HttpResponse apache_response = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 0), _appengine_hresponse.getResponseCode(), null);
for (HTTPHeader h : _appengine_hresponse.getHeaders()) {
apache_response.addHeader(h.getName(), h.getValue());
}
return apache_response;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicHttpResponse in project XobotOS by xamarin.
the class DefaultHttpResponseFactory method newHttpResponse.
// non-javadoc, see interface HttpResponseFactory
public HttpResponse newHttpResponse(final ProtocolVersion ver, final int status, HttpContext context) {
if (ver == null) {
throw new IllegalArgumentException("HTTP version may not be null");
}
final Locale loc = determineLocale(context);
final String reason = reasonCatalog.getReason(status, loc);
StatusLine statusline = new BasicStatusLine(ver, status, reason);
return new BasicHttpResponse(statusline, reasonCatalog, loc);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicHttpResponse in project camel by apache.
the class Olingo2AppImpl method parseResponse.
private Olingo2BatchResponse parseResponse(Edm edm, Map<String, String> contentIdLocationMap, Olingo2BatchRequest request, BatchSingleResponse response) throws EntityProviderException, ODataApplicationException {
// validate HTTP status
final int statusCode = Integer.parseInt(response.getStatusCode());
final String statusInfo = response.getStatusInfo();
final BasicHttpResponse httpResponse = new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, statusCode, statusInfo));
final Map<String, String> headers = response.getHeaders();
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpResponse.setHeader(entry.getKey(), entry.getValue());
}
ByteArrayInputStream content = null;
try {
if (response.getBody() != null) {
final ContentType partContentType = receiveWithCharsetParameter(ContentType.parse(headers.get(HttpHeaders.CONTENT_TYPE)), Consts.UTF_8);
final String charset = partContentType.getCharset().toString();
final String body = response.getBody();
content = body != null ? new ByteArrayInputStream(body.getBytes(charset)) : null;
httpResponse.setEntity(new StringEntity(body, charset));
}
AbstractFutureCallback.checkStatus(httpResponse);
} catch (ODataApplicationException e) {
return new Olingo2BatchResponse(statusCode, statusInfo, response.getContentId(), response.getHeaders(), e);
} catch (UnsupportedEncodingException e) {
return new Olingo2BatchResponse(statusCode, statusInfo, response.getContentId(), response.getHeaders(), e);
}
// resolve resource path and query params and parse batch part uri
final String resourcePath = request.getResourcePath();
final String resolvedResourcePath;
if (resourcePath.startsWith("$") && !(METADATA.equals(resourcePath) || BATCH.equals(resourcePath))) {
resolvedResourcePath = findLocation(resourcePath, contentIdLocationMap);
} else {
final String resourceLocation = response.getHeader(HttpHeaders.LOCATION);
resolvedResourcePath = resourceLocation != null ? resourceLocation.substring(serviceUri.length()) : resourcePath;
}
final Map<String, String> resolvedQueryParams = request instanceof Olingo2BatchQueryRequest ? ((Olingo2BatchQueryRequest) request).getQueryParams() : null;
final UriInfoWithType uriInfo = parseUri(edm, resolvedResourcePath, resolvedQueryParams);
// resolve response content
final Object resolvedContent = content != null ? readContent(uriInfo, content) : null;
return new Olingo2BatchResponse(statusCode, statusInfo, response.getContentId(), response.getHeaders(), resolvedContent);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicHttpResponse in project ddf by codice.
the class SolrHttpWrapper method execute.
@Override
public ResponseWrapper execute(URI uri) {
HttpResponse httpResponse;
HttpGet get = new HttpGet(uri);
try {
LOGGER.debug("Executing uri: {}", uri.toString());
httpResponse = solrClient.execute(get);
return new ResponseWrapper(httpResponse);
} catch (IOException e) {
LOGGER.debug("Error during request. Returning null response.");
}
BasicHttpResponse response = new BasicHttpResponse(null, HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error during request.");
return new ResponseWrapper(response);
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.message.BasicHttpResponse in project ddf by codice.
the class BackupCommandTest method prepareResponse.
private HttpResponse prepareResponse(int statusCode, String responseBody) {
HttpResponse httpResponse = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), statusCode, ""));
httpResponse.setStatusCode(statusCode);
try {
httpResponse.setEntity(new StringEntity(responseBody));
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e);
}
return httpResponse;
}
Aggregations