Module bus.http

Class TextCallback

java.lang.Object
org.miaixz.bus.http.plugin.httpz.TextCallback
All Implemented Interfaces:
Callback

public abstract class TextCallback extends Object implements Callback
An abstract Callback implementation for handling responses where the body is expected to be a text string.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • TextCallback

      public TextCallback()
  • Method Details

    • onResponse

      public void onResponse(NewCall call, Response response, String id)
      Handles the successful HTTP response by consuming the response body as a string and passing it to the onSuccess(NewCall, String, String) method.
      Specified by:
      onResponse in interface Callback
      Parameters:
      call - The NewCall that resulted in this response.
      response - The HTTP Response.
      id - The unique ID of the request.
    • onFailure

      public void onFailure(NewCall call, Exception e, String id)
      Handles request failures by logging the error.
      Specified by:
      onFailure in interface Callback
      Parameters:
      call - The NewCall that failed.
      e - The Exception that caused the failure.
      id - The unique ID of the request.
    • onSuccess

      public abstract void onSuccess(NewCall call, String response, String id)
      Abstract callback method invoked when a successful response with a text body is received. Subclasses must implement this method to handle the response string.
      Parameters:
      call - The NewCall that resulted in this response.
      response - The response body as a string.
      id - The unique ID of the request.