|
|
@ -113,23 +113,20 @@ public class HttpTask extends AbstractTask { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
String statusCode = null; |
|
|
|
String statusCode = null; |
|
|
|
String body = null; |
|
|
|
String body = null; |
|
|
|
try(CloseableHttpClient client = createHttpClient()) { |
|
|
|
|
|
|
|
try(CloseableHttpResponse response = sendRequest(client)) { |
|
|
|
try(CloseableHttpClient client = createHttpClient(); |
|
|
|
statusCode = String.valueOf(getStatusCode(response)); |
|
|
|
CloseableHttpResponse response = sendRequest(client)) { |
|
|
|
body = getResponseBody(response); |
|
|
|
statusCode = String.valueOf(getStatusCode(response)); |
|
|
|
exitStatusCode = validResponse(body, statusCode); |
|
|
|
body = getResponseBody(response); |
|
|
|
long costTime = System.currentTimeMillis() - startTime; |
|
|
|
exitStatusCode = validResponse(body, statusCode); |
|
|
|
logger.info("startTime: {}, httpUrl: {}, httpMethod: {}, costTime : {}Millisecond, statusCode : {}, body : {}, log : {}", |
|
|
|
long costTime = System.currentTimeMillis() - startTime; |
|
|
|
DateUtils.format2Readable(startTime), httpParameters.getUrl(),httpParameters.getHttpMethod(), costTime, statusCode, body, output); |
|
|
|
logger.info("startTime: {}, httpUrl: {}, httpMethod: {}, costTime : {}Millisecond, statusCode : {}, body : {}, log : {}", |
|
|
|
}catch (Exception e) { |
|
|
|
DateUtils.format2Readable(startTime), httpParameters.getUrl(),httpParameters.getHttpMethod(), costTime, statusCode, body, output); |
|
|
|
appendMessage(e.toString()); |
|
|
|
}catch (Exception e){ |
|
|
|
exitStatusCode = -1; |
|
|
|
|
|
|
|
logger.error("httpUrl[" + httpParameters.getUrl() + "] connection failed:"+output, e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
appendMessage(e.toString()); |
|
|
|
appendMessage(e.toString()); |
|
|
|
exitStatusCode = -1; |
|
|
|
exitStatusCode = -1; |
|
|
|
logger.error("httpUrl[" + httpParameters.getUrl() + "] connection failed:"+output, e); |
|
|
|
logger.error("httpUrl[" + httpParameters.getUrl() + "] connection failed:"+output, e); |
|
|
|
|
|
|
|
throw e; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|