Beispiel #1
0
 @Override
 public Object decode(Response response, Type type) throws IOException {
   Response.Body body = response.body();
   if (body == null) {
     return null;
   }
   if (String.class.equals(type)) {
     return Util.toString(body.asReader());
   }
   throw new DecodeException(format("%s is not a type supported by this decoder.", type));
 }
 @Override
 protected Response logAndRebufferResponse(
     String configKey, feign.Logger.Level logLevel, Response response, long elapsedTime)
     throws IOException {
   String requestId = requestIdProvider.getRequestId();
   HttpData reqData = requestDataProvider.retrieve(requestId);
   if (requestTraceable(reqData) && isNotSkipped(reqData)) {
     byte[] bodyData = Util.toByteArray(response.body().asInputStream());
     String content = new String(bodyData, StandardCharsets.UTF_8.name());
     HttpData resData = new HttpData(extractHeaders(response), extractStatus(response), content);
     Response rebufferedResponse =
         Response.create(response.status(), response.reason(), response.headers(), bodyData);
     requestResponseLogger.logObfuscatedResponse(reqData, resData, TAG);
     requestDataProvider.remove(requestId);
     return super.logAndRebufferResponse(configKey, logLevel, rebufferedResponse, elapsedTime);
   } else {
     log.debug("Cannot obfuscate response, matching request data lost");
     return super.logAndRebufferResponse(configKey, logLevel, response, elapsedTime);
   }
 }