Class HttpErrorResponseReceived

java.lang.Object
dev.langchain4j.http.client.sse.HttpErrorResponseReceived
All Implemented Interfaces:
HttpStreamingEvent

@Experimental public final class HttpErrorResponseReceived extends Object implements HttpStreamingEvent
HttpStreamingEvent signalling that the server answered with an error status (not 2xx). It is emitted as soon as the response headers arrive, before the response body is read, so it carries the status code and the headers, but not the body.

A subscriber that only needs the status code can cancel its subscription when it receives this event. The HTTP client then stops reading the response body. Otherwise, the stream fails as usual with an HttpException that contains the status code and the response body.

Not every HttpClient implementation emits this event, and it is emitted only when the subscriber has requested at least one item. Without it, the stream only fails with the HttpException.

Since:
1.23.0
  • Constructor Details

    • HttpErrorResponseReceived

      public HttpErrorResponseReceived(int statusCode, Map<String, List<String>> headers)
  • Method Details

    • statusCode

      public int statusCode()
    • headers

      public Map<String, List<String>> headers()
      Returns:
      the response headers. Header names are case-insensitive.
    • toString

      public String toString()
      Overrides:
      toString in class Object