mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-03 02:56:09 +00:00
fix 修复 WebFluxUtils 读取空 body 报 null 问题
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.gateway.utils;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.utils.JsonUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
@@ -79,7 +80,11 @@ public class WebFluxUtils {
|
||||
* @return body
|
||||
*/
|
||||
public static String resolveBodyFromCacheRequest(ServerWebExchange exchange) {
|
||||
DataBuffer buffer = (DataBuffer) exchange.getAttributes().get(ServerWebExchangeUtils.CACHED_REQUEST_BODY_ATTR);
|
||||
Object obj = exchange.getAttributes().get(ServerWebExchangeUtils.CACHED_REQUEST_BODY_ATTR);
|
||||
if (ObjectUtil.isNull(obj)) {
|
||||
return null;
|
||||
}
|
||||
DataBuffer buffer = (DataBuffer) obj;
|
||||
CharBuffer charBuffer = StandardCharsets.UTF_8.decode(buffer.asByteBuffer());
|
||||
return charBuffer.toString();
|
||||
}
|
||||
|
Reference in New Issue
Block a user