Closed stanxlab closed 2 years ago
The GET request header set content-type: application/x-www-form-urlencoded, RpcParamTransformPlugin will get body from HttpRequest, but in GET requset the body is empty, the parameters is in url query part.
content-type: application/x-www-form-urlencoded
The code is in the RpcParamTransformPlugin.java
RpcParamTransformPlugin.java
if (MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType)) { return formData(exchange, request, chain); } ... private Mono<Void> formData(final ServerWebExchange exchange, final ServerHttpRequest serverHttpRequest, final ShenyuPluginChain chain) { return Mono.from(serverHttpRequest.getBody() .flatMap(map -> { String param = resolveBodyFromRequest(map); LinkedMultiValueMap linkedMultiValueMap; try { linkedMultiValueMap = BodyParamUtils.buildBodyParams(URLDecoder.decode(param, StandardCharsets.UTF_8.name())); } catch (UnsupportedEncodingException e) { return Flux.error(e); } exchange.getAttributes().put(Constants.PARAM_TRANSFORM, HttpParamConverter.toMap(() -> linkedMultiValueMap)); return chain.execute(exchange); })); }
The GET request header set content-type: application/x-www-form-urlencoded, RpcParamTransformPlugin can get parameters from url query.
No response
ShenYu version(s): 2.4.1
why get request,set content-type "application/x-www-form-urlencoded " ?
@yu199195 I'm sorry. It's my fault. The header is set content-type "application/x-www-form-urlencoded" both get and post request.
Is there an existing issue for this?
Current Behavior
The GET request header set
content-type: application/x-www-form-urlencoded
, RpcParamTransformPlugin will get body from HttpRequest, but in GET requset the body is empty, the parameters is in url query part.The code is in the
RpcParamTransformPlugin.java
Expected Behavior
The GET request header set
content-type: application/x-www-form-urlencoded
, RpcParamTransformPlugin can get parameters from url query.Steps To Reproduce
No response
Environment
Debug logs
No response
Anything else?
No response