fix: Fix SseLineSubscriber lacking request. (#507)
Signed-off-by: He-Pin <hepin1989@gmail.com>
This commit is contained in:
parent
888e555026
commit
94c03505c1
1 changed files with 4 additions and 1 deletions
|
|
@ -141,7 +141,6 @@ class ResponseSubscribers {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void hookOnNext(String line) {
|
protected void hookOnNext(String line) {
|
||||||
|
|
||||||
if (line.isEmpty()) {
|
if (line.isEmpty()) {
|
||||||
// Empty line means end of event
|
// Empty line means end of event
|
||||||
if (this.eventBuilder.length() > 0) {
|
if (this.eventBuilder.length() > 0) {
|
||||||
|
|
@ -158,23 +157,27 @@ class ResponseSubscribers {
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
this.eventBuilder.append(matcher.group(1).trim()).append("\n");
|
this.eventBuilder.append(matcher.group(1).trim()).append("\n");
|
||||||
}
|
}
|
||||||
|
upstream().request(1);
|
||||||
}
|
}
|
||||||
else if (line.startsWith("id:")) {
|
else if (line.startsWith("id:")) {
|
||||||
var matcher = EVENT_ID_PATTERN.matcher(line);
|
var matcher = EVENT_ID_PATTERN.matcher(line);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
this.currentEventId.set(matcher.group(1).trim());
|
this.currentEventId.set(matcher.group(1).trim());
|
||||||
}
|
}
|
||||||
|
upstream().request(1);
|
||||||
}
|
}
|
||||||
else if (line.startsWith("event:")) {
|
else if (line.startsWith("event:")) {
|
||||||
var matcher = EVENT_TYPE_PATTERN.matcher(line);
|
var matcher = EVENT_TYPE_PATTERN.matcher(line);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
this.currentEventType.set(matcher.group(1).trim());
|
this.currentEventType.set(matcher.group(1).trim());
|
||||||
}
|
}
|
||||||
|
upstream().request(1);
|
||||||
}
|
}
|
||||||
else if (line.startsWith(":")) {
|
else if (line.startsWith(":")) {
|
||||||
// Ignore comment lines starting with ":"
|
// Ignore comment lines starting with ":"
|
||||||
// This is a no-op, just to skip comments
|
// This is a no-op, just to skip comments
|
||||||
logger.debug("Ignoring comment line: {}", line);
|
logger.debug("Ignoring comment line: {}", line);
|
||||||
|
upstream().request(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If the response is not successful, emit an error
|
// If the response is not successful, emit an error
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue