@@ -245,7 +245,7 @@ private Publisher<Void> createDelete(String sessionId) {
245245 () -> this .httpClient .sendAsync (requestBuilder .build (), HttpResponse .BodyHandlers .ofPublisher ()))
246246 // The response is not inspected, but the body still has to be consumed
247247 // to release the connection.
248- .flatMapMany (response -> ResponseSubscribers .drain (response .body (), this .maxResponseSize ))
248+ .flatMapMany (response -> ResponseBodyHandlers .drain (response .body (), this .maxResponseSize ))
249249 .then ())
250250 .then ();
251251 }
@@ -286,8 +286,8 @@ public Mono<Void> closeGracefully() {
286286 private Flux <McpSchema .JSONRPCMessage > consumeSseStream (
287287 java .util .concurrent .Flow .Publisher <List <java .nio .ByteBuffer >> body ,
288288 McpTransportStream <Disposable > existingStream , Runnable onFirstMessage ) {
289- Flux <String > lines = ResponseSubscribers .decodeLines (body , this .maxResponseSize );
290- return ResponseSubscribers .decodeSseResponse (lines , this .maxResponseSize ).flatMap (sseEvent -> {
289+ Flux <String > lines = ResponseBodyHandlers .decodeLines (body , this .maxResponseSize );
290+ return ResponseBodyHandlers .decodeSseResponse (lines , this .maxResponseSize ).flatMap (sseEvent -> {
291291 if (!isMessageEvent (sseEvent .event ())) {
292292 logger .debug ("Received SSE event with type: {}" , sseEvent );
293293 if (onFirstMessage != null ) {
@@ -434,9 +434,9 @@ else if (statusCode >= 200 && statusCode < 300) {
434434
435435 return proceed ? consumeSseStream (httpResponse .body (), stream , null )
436436 : exception != null
437- ? ResponseSubscribers .drainThenError (httpResponse .body (), this .maxResponseSize ,
437+ ? ResponseBodyHandlers .drainThenError (httpResponse .body (), this .maxResponseSize ,
438438 exception )
439- : ResponseSubscribers .drain (httpResponse .body (), this .maxResponseSize );
439+ : ResponseBodyHandlers .drain (httpResponse .body (), this .maxResponseSize );
440440 });
441441 })
442442 .retryWhen (authorizationErrorRetrySpec ())
@@ -555,7 +555,7 @@ public Mono<Void> sendMessage(McpSchema.JSONRPCMessage sentMessage) {
555555 var request = requestBuilder .build ();
556556 var requestSnapshot = new HttpRequestSnapshot (request .uri (), request .method (),
557557 request .headers ());
558- return ResponseSubscribers .drainThenError (httpResponse .body (), this .maxResponseSize ,
558+ return ResponseBodyHandlers .drainThenError (httpResponse .body (), this .maxResponseSize ,
559559 new McpHttpClientTransportAuthorizationException (
560560 "Authorization error when sending message" , requestSnapshot ,
561561 toResponseInfo (httpResponse )));
@@ -580,7 +580,7 @@ public Mono<Void> sendMessage(McpSchema.JSONRPCMessage sentMessage) {
580580 if (contentType .isBlank () || "0" .equals (contentLength ) || statusCode == 202 ) {
581581 logger .debug ("No body returned for POST in session {}" , sessionRepresentation );
582582 deliveredSink .success ();
583- return ResponseSubscribers .drain (httpResponse .body (), this .maxResponseSize );
583+ return ResponseBodyHandlers .drain (httpResponse .body (), this .maxResponseSize );
584584 }
585585 else if (contentType .contains (TEXT_EVENT_STREAM )) {
586586 AtomicBoolean delivered = new AtomicBoolean ();
@@ -591,7 +591,7 @@ else if (contentType.contains(TEXT_EVENT_STREAM)) {
591591 });
592592 }
593593 else if (contentType .contains (APPLICATION_JSON )) {
594- return ResponseSubscribers
594+ return ResponseBodyHandlers
595595 .decodeAggregateResponse (httpResponse .body (), this .maxResponseSize )
596596 .flatMapMany (data -> {
597597 deliveredSink .success ();
@@ -612,34 +612,34 @@ else if (contentType.contains(APPLICATION_JSON)) {
612612
613613 logger .warn ("Unknown media type {} returned for POST in session {}" , contentType ,
614614 sessionRepresentation );
615- return ResponseSubscribers .drainThenError (httpResponse .body (), this .maxResponseSize ,
615+ return ResponseBodyHandlers .drainThenError (httpResponse .body (), this .maxResponseSize ,
616616 new RuntimeException ("Unknown media type returned: " + contentType ));
617617 }
618618 else if (statusCode == NOT_FOUND ) {
619619 if (maybeSessionId .isPresent ()) {
620620 logger .debug ("Session not found for session ID: {}" , sessionRepresentation );
621- return ResponseSubscribers .drainThenError (httpResponse .body (), this .maxResponseSize ,
621+ return ResponseBodyHandlers .drainThenError (httpResponse .body (), this .maxResponseSize ,
622622 new McpTransportSessionNotFoundException (
623623 "Session not found for session ID: " + sessionRepresentation ));
624624 }
625- return ResponseSubscribers .drainThenError (httpResponse .body (), this .maxResponseSize ,
625+ return ResponseBodyHandlers .drainThenError (httpResponse .body (), this .maxResponseSize ,
626626 new McpTransportException ("Server Not Found. Status code:" + statusCode ));
627627 }
628628 else if (statusCode == BAD_REQUEST ) {
629629 if (maybeSessionId .isPresent ()) {
630- return ResponseSubscribers .drainThenError (httpResponse .body (), this .maxResponseSize ,
630+ return ResponseBodyHandlers .drainThenError (httpResponse .body (), this .maxResponseSize ,
631631 new McpTransportSessionNotFoundException (
632632 "Session not found for session ID: " + sessionRepresentation ));
633633 }
634- return ResponseSubscribers .drainThenError (httpResponse .body (), this .maxResponseSize ,
634+ return ResponseBodyHandlers .drainThenError (httpResponse .body (), this .maxResponseSize ,
635635 new McpTransportException ("Bad Request. Status code:" + statusCode ));
636636 }
637637 else if (statusCode >= 400 && statusCode < 500 ) {
638- return ResponseSubscribers .drainThenError (httpResponse .body (), this .maxResponseSize ,
638+ return ResponseBodyHandlers .drainThenError (httpResponse .body (), this .maxResponseSize ,
639639 new McpTransportException ("Invalid request. Status code: " + statusCode ));
640640 }
641641
642- return ResponseSubscribers .drainThenError (httpResponse .body (), this .maxResponseSize ,
642+ return ResponseBodyHandlers .drainThenError (httpResponse .body (), this .maxResponseSize ,
643643 new RuntimeException ("Failed to send message, status code: " + statusCode ));
644644 })
645645 .onErrorMap (CompletionException .class , Throwable ::getCause ))
0 commit comments