Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
cp committed Sep 29, 2018
1 parent 1c4daa0 commit 3fe2d61
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main/java/com/jutils/jhttp/http/request/HttpManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ private Object service(String method, HttpResultListeners callback) {
resultObject = MakeRequest(method);

} catch (Exception e) {
log.error(TAG + " -> " + "Error: " + e.getLocalizedMessage());
exp = e;
}
//Ejecutamos los callback
Expand All @@ -169,7 +170,7 @@ private Object service(String method, HttpResultListeners callback) {
log.error(TAG + " -> " + e.getMessage());
}
}
log.info(TAG + " -> " + "Finalizando petición;Disconnecting Connection");
log.debug(TAG + " -> " + "Finalizando petición; Disconnecting Connection");
this.httpConnection.disconnect();
return resultObject;
}
Expand All @@ -185,14 +186,14 @@ private Object MakeRequest(String method) throws Exception {
this.httpConnection.setRequestMethod(method);
this.httpConnection.setConnectTimeout(TIME_OUT);
this.httpConnection.setDoInput(true);//Permitir recepcion de datos
log.info(TAG + " -> " + "Request Detail: URL [ " + this.url + " ] Method [ " + method + " ]\n timeout time [ "
log.debug(TAG + " -> " + "Request Detail: URL [ " + this.url + " ] Method [ " + method + " ]\n timeout time [ "
+ TIME_OUT + " ] responseType [ " + this.responseClass.getSimpleName() + " ]\n ");

//Agregamos los headers a la petición
fillRequestWithHeaders();
//Convertimos los parametros enviados a string para enviarlos en la peticion
Object valueToRequest = HttpManagerUtils.convertParamsToValue(params);

if (!HttpManagerUtils.isEmpty(valueToRequest)) {
if (!method.equals(this.GET)) {
//Si no es una entidad de tipo nativa como Integer,Double... etc, Agregar serializado a la peticion
Expand All @@ -212,7 +213,7 @@ private Object MakeRequest(String method) throws Exception {
dos.flush();
dos.close();

log.info(TAG + " -> " + "Content-Type [ "
log.debug(TAG + " -> " + "Content-Type [ "
+ this.httpConnection.getContentType() + " ].");

}
Expand Down Expand Up @@ -257,7 +258,7 @@ private Object convertResponseToResult() throws Exception {
response.setContentType(this.httpConnection.getContentType());
result = response;

log.info(TAG + " -> " + "Tipo de dato a retornar: Stream");
log.debug(TAG + " -> " + "Tipo de dato a retornar: Stream");

} else {

Expand All @@ -271,9 +272,10 @@ private Object convertResponseToResult() throws Exception {

if (this.bReader != null) {
serverMessage = HttpManagerUtils.frombufferReader(this.bReader);
log.info(TAG + " -> " + "Respuesta del servidor: " + serverMessage);
log.debug(TAG + " -> " + "Respuesta del servidor: " + serverMessage);
//Si la peticion retornó error
if (!isSuccess) {
log.error(TAG + " -> " + "Not success answer from server");
throw new HttpManagerInternalException(serverMessage);
}
}
Expand All @@ -284,10 +286,10 @@ private Object convertResponseToResult() throws Exception {
result = serverMessage;
} else if (this.isArrayResponse) {
result = HttpManagerConverterFactory.DeserializeArray(responseClass, serverMessage);
log.info(TAG + " -> " + "Tipo de dato a retornar: List<" + ((Class) responseClass).getName() + ">");
log.debug(TAG + " -> " + "Tipo de dato a retornar: List<" + ((Class) responseClass).getName() + ">");
} else {
result = HttpManagerConverterFactory.DeserializeObject(responseClass, serverMessage);
log.info(TAG + " -> " + "Tipo de dato a retornar: " + ((Class) responseClass).getName());
log.debug(TAG + " -> " + "Tipo de dato a retornar: " + ((Class) responseClass).getName());
}
}
}
Expand All @@ -307,7 +309,7 @@ public HttpManager setHeader(String key, String value) {
}
this.RequestHeaders.put(key, value);

log.info(TAG + " -> " + "Agregando header: " + key + " valor:" + value);
log.debug(TAG + " -> " + "Agregando header: " + key + " valor:" + value);
return this;
}

Expand Down

0 comments on commit 3fe2d61

Please sign in to comment.