[ 
https://issues.apache.org/jira/browse/CXF-8629?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17906472#comment-17906472
 ] 

John Yin commented on CXF-8629:
-------------------------------

I tested this with the latest 4.1.0 release.   After varying different factors, 
I think the duplicate response issue occurs when 1) the hc5 jar is in the 
classpath, and 2) when AutoRedirect="true" is specified in the conduit (even 
when the server did not suggest to redirect).  Since I only use CXF from Camel, 
here is my test script (groovy) using Camel:
{quote}from("timer://testRoute2?repeatCount=1")                                 
// send a http POST to server, and print out the response
.process({
it.in.setBody('\{"name":"john"}')
it.in.setHeader('cache-control', 'no-cache')
it.in.setHeader('Content-Type', 'application/json')
it.in.setHeader('CamelHttpMethod', 'POST')
})
.setExchangePattern(ExchangePattern.InOut)
.to("cxfrs:bean:rsClientTest")
.log('response received: $simple\{body}')
 
from("cxfrs:bean:rsServerTest?bindingStyle=SimpleConsumer")   // receive HTTP 
request, printout the request, and send back a response
.log('request received: $simple\{body}')
.process ({
it.in.setHeader('Content-Type', 'application/json')
it.in.setBody('\{"result":"ok"}')
}){quote}
 
This will produce the following output (when hc5 is used and 
AutoRedirect="true" is specified in the conduit.  The response from server is 
received or processed twice by the client, one had payload, one did not.
{quote}2024-12-17 11:18:35.496 [Camel (camel-1) thread #32 - 
timer://testRoute2] LoggingOutInterceptor - Outbound Message - *by client*
---------------------------
ID: 1
Address: http://localhost:8081/test/url
Http-Method: POST
Content-Type: application/json
Headers: \{cache-control=[no-cache], Content-Type=[application/json], 
Content-Language=[en_US], Connection=[Keep-Alive], Accept=[*/*]}
Payload: \{"name":"john"}
--------------------------------------
2024-12-17 11:18:35.612 [qtp2019773797-116] LoggingInInterceptor - Inbound 
Message - *by server*
----------------------------
ID: 2
Address: http://localhost:8081/test/url
Encoding: UTF-8
Http-Method: POST
Content-Type: application/json
Headers: \{Accept=[*/*], Cache-Control=[no-cache], connection=[keep-alive], 
Content-Language=[en_US], Content-Length=[15], content-type=[application/json], 
Host=[localhost:8081], User-Agent=[Apache CXF 4.1.0]}
Payload: \{"name":"john"}
--------------------------------------
2024-12-17 11:18:35.630 [qtp2019773797-116] route16 - request received: 
\{"name":"john"}
2024-12-17 11:18:35.645 [qtp2019773797-116] LoggingOutInterceptor - Outbound 
Message - *by server*
---------------------------
ID: 2
Response-Code: 200
Content-Type: application/json
Headers: \{Accept=[*/*], Cache-Control=[no-cache], User-Agent=[Apache CXF 
4.1.0], connection=[keep-alive], Host=[localhost:8081], 
Content-Language=[en_US], Content-Type=[application/json], Date=[Tue, 17 Dec 
2024 16:18:35 GMT]}
Payload: \{"result":"ok"}
--------------------------------------
2024-12-17 11:18:35.658 [default-workqueue-1] LoggingInInterceptor - Inbound 
Message - *by client*
----------------------------
*ID: 1*
Response-Code: 200
Encoding: ISO-8859-1
Content-Type: application/json
Headers: \{Accept=[*/*], Cache-Control=[no-cache], Content-Language=[en_US], 
Content-Type=[application/json], Date=[Tue, 17 Dec 2024 16:18:35 GMT], 
Host=[localhost:8081], Server=[Jetty(12.0.15)], Transfer-Encoding=[chunked], 
User-Agent=[Apache CXF 4.1.0]}
Payload: *{"result":"ok"}*
--------------------------------------
2024-12-17 11:18:35.660 [default-workqueue-2] LoggingInInterceptor - Inbound 
Message  -{*}by client but no payload{*}
----------------------------
*ID: 1*
Response-Code: 200
Encoding: ISO-8859-1
Content-Type: application/json
Headers: \{Accept=[*/*], Cache-Control=[no-cache], Content-Language=[en_US], 
Content-Type=[application/json], Date=[Tue, 17 Dec 2024 16:18:35 GMT], 
Host=[localhost:8081], Server=[Jetty(12.0.15)], Transfer-Encoding=[chunked], 
User-Agent=[Apache CXF 4.1.0]}
--------------------------------------
2024-12-17 11:18:35.665 [default-workqueue-1] route17 - response received: 
{quote}
 
If AutoRedirect is removed or set to false, everything would work as expected:
{quote}<http:conduit name=".*">
   <http:client AllowChunking="false"
       *AutoRedirect="true"*
       ProxyServer=""
       ProxyServerPort="0"
       ConnectionTimeout="30"
       ReceiveTimeout="90"
       Connection="Keep-Alive"
   />
</http:conduit>{quote}

> AsyncHTTPConduit (hc5) should support chunked request / response
> ----------------------------------------------------------------
>
>                 Key: CXF-8629
>                 URL: https://issues.apache.org/jira/browse/CXF-8629
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 3.5.0, 3.4.5
>            Reporter: Andriy Redko
>            Assignee: Andriy Redko
>            Priority: Major
>             Fix For: 4.1.0, 3.5.10, 3.6.5, 4.0.6
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to