Public MonoThe filter (ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpResponse originalResponse=exchange. The method getResponse ();
DataBufferFactory bufferFactory=originalResponse. BufferFactory ();
ServerHttpResponseDecorator decoratedResponse=new ServerHttpResponseDecorator (originalResponse) {
@ Override
Public MonoWriteWith (Publisher<? Extends DataBuffer> Body) {
If (body instanceof Flux) {
Flux<? Extends DataBuffer> FluxBody=(Flux<? Extends DataBuffer>) The body;
Return super. WriteWith (fluxBody. The map (dataBuffer - & gt; {
//probably should reuse buffers
Byte [] the content=new byte [dataBuffer readableByteCount ()];
DataBuffer. Read (content);
//release memory
DataBufferUtils. Release (dataBuffer);
String s=new String (the content, the Charset. Class.forname (" utf-8 "));
//TODO, s is the value of the response
Byte [] uppedContent=new String (the content, the Charset. Class.forname (" utf-8 ")). GetBytes ();
Return bufferFactory. Wrap (uppedContent);
}));
}
//if the body is not a flux. Never got there.
Return super. WriteWith (body);
}
};
//replace the response with the decorator
Return chain. The filter (exchange. Mutate (). The response (decoratedResponse). The build ());
}
View the return information, found that the contentType is null?
CodePudding user response:
Calls the method is a c # GetRequestStream () methodCodePudding user response:
There are a great god please help?CodePudding user response:
Remove the filter you configured to direct, to test, should be the filter you have any question, enhance the log, recording analysis analysisCodePudding user response: