use of org.apache.http.message.BasicRequestLine in project elasticsearch by elastic.
the class FailureTrackingResponseListenerTests method mockResponse.
private static Response mockResponse() {
ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
RequestLine requestLine = new BasicRequestLine("GET", "/", protocolVersion);
StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "OK");
HttpResponse httpResponse = new BasicHttpResponse(statusLine);
return new Response(requestLine, new HttpHost("localhost", 9200), httpResponse);
}
use of org.apache.http.message.BasicRequestLine in project XobotOS by xamarin.
the class HttpRequestBase method getRequestLine.
public RequestLine getRequestLine() {
String method = getMethod();
ProtocolVersion ver = getProtocolVersion();
URI uri = getURI();
String uritext = null;
if (uri != null) {
uritext = uri.toASCIIString();
}
if (uritext == null || uritext.length() == 0) {
uritext = "/";
}
return new BasicRequestLine(method, uritext, ver);
}
use of org.apache.http.message.BasicRequestLine in project robovm by robovm.
the class HttpRequestBase method getRequestLine.
public RequestLine getRequestLine() {
String method = getMethod();
ProtocolVersion ver = getProtocolVersion();
URI uri = getURI();
String uritext = null;
if (uri != null) {
uritext = uri.toASCIIString();
}
if (uritext == null || uritext.length() == 0) {
uritext = "/";
}
return new BasicRequestLine(method, uritext, ver);
}
use of org.apache.http.message.BasicRequestLine in project LogHub by fbacchella.
the class AbstractHttpSender method doRequest.
protected HttpResponse doRequest(HttpRequest therequest) {
CloseableHttpResponse response = null;
HttpClientContext context = HttpClientContext.create();
if (credsProvider != null) {
context.setCredentialsProvider(credsProvider);
}
HttpHost host;
RequestLine requestLine = new BasicRequestLine(therequest.verb, therequest.url.getPath(), therequest.httpVersion);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(requestLine);
if (therequest.content != null) {
request.setEntity(therequest.content);
}
therequest.headers.forEach((i, j) -> request.addHeader(i, j));
host = new HttpHost(therequest.url.getHost(), therequest.url.getPort(), therequest.url.getProtocol());
try {
response = client.execute(host, request, context);
} catch (ConnectionPoolTimeoutException e) {
logger.error("Connection to {} timed out", host);
return new HttpResponse(host, null, e, null);
} catch (HttpHostConnectException e) {
String message = "";
try {
throw e.getCause();
} catch (ConnectException e1) {
message = String.format("Connection to %s refused", host);
} catch (SocketTimeoutException e1) {
message = String.format("Slow response from %s", host);
} catch (Throwable e1) {
message = String.format("Connection to %s failed: %s", host, e1.getMessage());
logger.catching(Level.DEBUG, e1);
}
logger.error(message);
logger.catching(Level.DEBUG, e.getCause());
return new HttpResponse(host, null, e, null);
} catch (IOException e) {
Throwable rootCause = e;
while (rootCause.getCause() != null) {
rootCause = rootCause.getCause();
}
;
// A TLS exception, will not help to retry
if (rootCause instanceof GeneralSecurityException) {
logger.error("Secure comunication with {} failed: {}", host, rootCause.getMessage());
logger.catching(Level.DEBUG, rootCause);
return new HttpResponse(host, null, null, (GeneralSecurityException) rootCause);
} else {
logger.error("Comunication with {} failed: {}", host, e.getMessage());
logger.catching(Level.DEBUG, e);
return new HttpResponse(host, null, e, null);
}
}
if (response == null) {
logger.error("give up trying to connect to " + getPublishName());
return null;
}
;
return new HttpResponse(host, response, null, null);
}
use of org.apache.http.message.BasicRequestLine in project platform_external_apache-http by android.
the class RequestWrapper method getRequestLine.
public RequestLine getRequestLine() {
String method = getMethod();
ProtocolVersion ver = getProtocolVersion();
String uritext = null;
if (uri != null) {
uritext = uri.toASCIIString();
}
if (uritext == null || uritext.length() == 0) {
uritext = "/";
}
return new BasicRequestLine(method, uritext, ver);
}
Aggregations