dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

[Bug] Rest request can not handle custom header's value correctly

Open MartinDai opened this issue 1 year ago • 0 comments

Pre-check

  • [X] I am sure that all the content I provide is in English.

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

3.2.15

Steps to reproduce this issue

Start a dubbo provider service register by rest protocol with config version or group

In my case the register log is on below

2024-08-13T17:03:56.633+08:00  INFO 31907 --- [springboot-dubbo-provider] [           main] o.a.d.r.zookeeper.ZookeeperRegistry      :  [DUBBO] Register: rest://198.19.249.3:8080/com.doodl6.springboot.dubbo.api.FirstDubboService?application=springboot-dubbo-service-local&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=com.doodl6.springboot.dubbo.api.FirstDubboService&methods=getDubboInfo&prefer.serialization=fastjson2,hessian2&release=3.2.15&revision=1.0-local&server=netty&service-name-mapping=true&side=provider&timeout=10000&timestamp=1723539836485&version=1.0-local, dubbo version: 3.2.15, current host: 198.19.249.3

Then, start a another consumer service to invoke the service use rest protocol. By default, dubbo will use okhttp to send http request,

After send the request, here is the provider service's log

POST /dubbo-rest/getDubboInfo HTTP/1.1
Host: 198.19.249.3:8080
User-Agent: okhttp/4.12.0
Content-Length: 8
Accept: application/json; charset=UTF-8
Accept-Encoding: gzip
Content-Type: application/json
Rest-Service-Path: com.doodl6.springboot.dubbo.api.FirstDubboService
Rest-Service-Remote.application: springboot-web-local
Rest-Service-Version: 1.0-local, dubbo version: 3.2.15, current host: 198.19.249.3, error code: . This may be caused by rest service Path no found, current path info:PathMatcher{path='/dubbo-rest/getDubboInfo', version='null', group='null', port=null, hasPathVariable=false, contextPath='null', httpMethod='POST'}, go to  to find instructions. 

org.apache.dubbo.rpc.protocol.rest.exception.PathNoFoundException: rest service Path no found, current path info:PathMatcher{path='/dubbo-rest/getDubboInfo', version='null', group='null', port=null, hasPathVariable=false, contextPath='null', httpMethod='POST'}
	at org.apache.dubbo.rpc.protocol.rest.filter.ServiceInvokeRestFilter.doHandler(ServiceInvokeRestFilter.java:90) ~[dubbo-3.2.15.jar:3.2.15]
	at org.apache.dubbo.rpc.protocol.rest.filter.ServiceInvokeRestFilter.filter(ServiceInvokeRestFilter.java:69) ~[dubbo-3.2.15.jar:3.2.15]
	at org.apache.dubbo.rpc.protocol.rest.handler.NettyHttpHandler.executeFilters(NettyHttpHandler.java:152) ~[dubbo-3.2.15.jar:3.2.15]
	at org.apache.dubbo.rpc.protocol.rest.handler.NettyHttpHandler.handle(NettyHttpHandler.java:84) ~[dubbo-3.2.15.jar:3.2.15]
	at org.apache.dubbo.rpc.protocol.rest.netty.RestHttpRequestDecoder.lambda$decode$0(RestHttpRequestDecoder.java:69) ~[dubbo-3.2.15.jar:3.2.15]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
	at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:39) ~[dubbo-common-3.2.15.jar:3.2.15]
	at java.base/java.lang.Thread.run(Thread.java:840) ~[na:na]

The reason is okhttp formatted the request header's name to Upper Camel Case, but in provider side, it only use the original header's name to get value QQ_1723541821021

What you expected to happen

Provider side service can handle the custom header's value correctly

Anything else

No response

Are you willing to submit a pull request to fix on your own?

  • [ ] Yes I am willing to submit a pull request on my own!

Code of Conduct

MartinDai avatar Aug 13 '24 09:08 MartinDai