Skip to content

Commit

Permalink
Merge branch '6.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze committed Oct 18, 2024
2 parents cee8b52 + 5e28a25 commit 5abe5e1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response)
String path = request.getURI().getPath();
return switch (path) {
case "/write-and-flush" -> response.writeAndFlushWith(
testInterval(Duration.ofMillis(50), 2)
testInterval(Duration.ofMillis(1), 2)
.map(longValue -> wrap("data" + longValue + "\n", response))
.map(Flux::just)
.mergeWith(Flux.never()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void sseAsEvent(HttpServer httpServer) throws Exception {

private static class SseHandler {

private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(100), 2);
private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(1), 2);

Mono<ServerResponse> string(ServerRequest request) {
return ServerResponse.ok()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static class JacksonStreamingController {
@GetMapping(value = "/stream",
produces = { APPLICATION_NDJSON_VALUE, "application/stream+x-jackson-smile" })
Flux<Person> person() {
return testInterval(Duration.ofMillis(100), 50).map(l -> new Person("foo " + l));
return testInterval(Duration.ofMillis(1), 50).map(l -> new Person("foo " + l));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Flux<Msg> messages() {

@GetMapping(value = "/message-stream", produces = "application/x-protobuf;delimited=true")
Flux<Msg> messageStream() {
return testInterval(Duration.ofMillis(50), 5).map(l ->
return testInterval(Duration.ofMillis(1), 5).map(l ->
Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(l.intValue()).build()).build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.function.Predicate;

import org.reactivestreams.Publisher;
import reactor.core.publisher.Mono;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
Expand All @@ -34,6 +35,8 @@
import org.springframework.http.ResponseEntity;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -116,6 +119,13 @@ void stream(HttpServer httpServer) throws Exception {
assertThat(performGet("/stream", new HttpHeaders(), int[].class).getBody()).isEqualTo(expected);
}

@ParameterizedHttpServerTest // gh-33739
void requestBodyAndDelayedResponse(HttpServer httpServer) throws Exception {
startServer(httpServer);

assertThat(performPost("/post", new HttpHeaders(), "text", String.class).getBody()).isEqualTo("text");
}


@Configuration
@EnableWebFlux
Expand Down Expand Up @@ -177,8 +187,14 @@ public String uri(ServerHttpRequest request) {

@GetMapping("/stream")
public Publisher<Long> stream() {
return testInterval(Duration.ofMillis(50), 5);
return testInterval(Duration.ofMillis(1), 5);
}

@PostMapping("/post")
public Mono<String> postDelayedInput(@RequestBody String text) {
return Mono.just(text).delayElement(Duration.ofMillis(1));
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void serverDetectsClientDisconnect(HttpServer httpServer, ClientHttpConnector co
@RequestMapping("/sse")
static class SseController {

private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(100), 50);
private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(1), 50);

private final Sinks.Empty<Void> cancelSink = Sinks.empty();

Expand Down

0 comments on commit 5abe5e1

Please sign in to comment.