Skip to content

Commit

Permalink
[type:refactor] adjust code order and remove invalid input parameters (
Browse files Browse the repository at this point in the history
…#5397)

Co-authored-by: hdgaadd <[email protected]>
Co-authored-by: dragon-zhang <[email protected]>
3 people authored Jan 30, 2024
1 parent 07aa062 commit a0db13a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -96,16 +96,16 @@ static class ModifyResponseDecorator extends ServerHttpResponseDecorator {
@Override
@NonNull
public Mono<Void> writeWith(@NonNull final Publisher<? extends DataBuffer> body) {
modifyResponseHeadersAndStatus();
final Mono<DataBuffer> dataBufferMono = DataBufferUtils.join(body);
buildModifiedResponse(body);
return dataBufferMono.flatMap(dataBuffer -> {
byte[] bytes = new byte[dataBuffer.readableByteCount()];
dataBuffer.read(bytes);
return WebFluxResultUtils.result(this.exchange, modifyBody(bytes));
});
}

private void buildModifiedResponse(final Publisher<? extends DataBuffer> body) {
private void modifyResponseHeadersAndStatus() {
HttpHeaders httpHeaders = new HttpHeaders();
// add origin headers
httpHeaders.addAll(this.getHeaders());

0 comments on commit a0db13a

Please sign in to comment.