Skip to content

Commit 94c0350

Browse files
authored
fix: Fix SseLineSubscriber lacking request. (#507)
Signed-off-by: He-Pin <[email protected]>
1 parent 888e555 commit 94c0350

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mcp/src/main/java/io/modelcontextprotocol/client/transport/ResponseSubscribers.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ protected void hookOnSubscribe(Subscription subscription) {
141141

142142
@Override
143143
protected void hookOnNext(String line) {
144-
145144
if (line.isEmpty()) {
146145
// Empty line means end of event
147146
if (this.eventBuilder.length() > 0) {
@@ -158,23 +157,27 @@ protected void hookOnNext(String line) {
158157
if (matcher.find()) {
159158
this.eventBuilder.append(matcher.group(1).trim()).append("\n");
160159
}
160+
upstream().request(1);
161161
}
162162
else if (line.startsWith("id:")) {
163163
var matcher = EVENT_ID_PATTERN.matcher(line);
164164
if (matcher.find()) {
165165
this.currentEventId.set(matcher.group(1).trim());
166166
}
167+
upstream().request(1);
167168
}
168169
else if (line.startsWith("event:")) {
169170
var matcher = EVENT_TYPE_PATTERN.matcher(line);
170171
if (matcher.find()) {
171172
this.currentEventType.set(matcher.group(1).trim());
172173
}
174+
upstream().request(1);
173175
}
174176
else if (line.startsWith(":")) {
175177
// Ignore comment lines starting with ":"
176178
// This is a no-op, just to skip comments
177179
logger.debug("Ignoring comment line: {}", line);
180+
upstream().request(1);
178181
}
179182
else {
180183
// If the response is not successful, emit an error

0 commit comments

Comments
 (0)