|
|
@ -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(); |
|
|
|
|
|
|
|
CloseableHttpResponse response = sendRequest(client)) { |
|
|
|
statusCode = String.valueOf(getStatusCode(response)); |
|
|
|
statusCode = String.valueOf(getStatusCode(response)); |
|
|
|
body = getResponseBody(response); |
|
|
|
body = getResponseBody(response); |
|
|
|
exitStatusCode = validResponse(body, statusCode); |
|
|
|
exitStatusCode = validResponse(body, statusCode); |
|
|
|
long costTime = System.currentTimeMillis() - startTime; |
|
|
|
long costTime = System.currentTimeMillis() - startTime; |
|
|
|
logger.info("startTime: {}, httpUrl: {}, httpMethod: {}, costTime : {}Millisecond, statusCode : {}, body : {}, log : {}", |
|
|
|
logger.info("startTime: {}, httpUrl: {}, httpMethod: {}, costTime : {}Millisecond, statusCode : {}, body : {}, log : {}", |
|
|
|
DateUtils.format2Readable(startTime), httpParameters.getUrl(),httpParameters.getHttpMethod(), costTime, statusCode, body, output); |
|
|
|
DateUtils.format2Readable(startTime), httpParameters.getUrl(),httpParameters.getHttpMethod(), costTime, statusCode, body, output); |
|
|
|
}catch (Exception e) { |
|
|
|
}catch (Exception e){ |
|
|
|
appendMessage(e.toString()); |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|