Skip to content

Commit

Permalink
Add java logging for auth server response.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaokai2 authored and pedroigor committed Aug 30, 2022
1 parent df1384f commit 0c654fa
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
Expand All @@ -47,6 +49,7 @@ public class HttpMethod<R> {
protected final Configuration configuration;
protected final Map<String, String> headers;
protected final Map<String, List<String>> params;
private static final Logger logger = Logger.getLogger(HttpMethod.class.getName());
private HttpMethodResponse<R> response;

public HttpMethod(Configuration configuration, ClientAuthenticator authenticator, RequestBuilder builder) {
Expand Down Expand Up @@ -91,6 +94,10 @@ public R execute(HttpResponseProcessor<R> responseProcessor) {
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();

if(logger.isLoggable(Level.FINE)) {
logger.fine( "Response from server: " + statusCode + " / " + statusLine.getReasonPhrase() + " / Body : " + new String(bytes != null? bytes: new byte[0]));
}

if (statusCode < 200 || statusCode >= 300) {
throw new HttpResponseException("Unexpected response from server: " + statusCode + " / " + statusLine.getReasonPhrase(), statusCode, statusLine.getReasonPhrase(), bytes);
}
Expand Down

0 comments on commit 0c654fa

Please sign in to comment.