talend tRESTClient 怀疑问题 204 No Content response without "content-length: 0" header

talend tRESTClient suspected issues with 204 No Content response without "content-length: 0" header

我们使用 talend 来构建 ETL。我们使用的组件之一是 tRESTClient,用于与我们平台中的 REST 服务进行交互。我们使用 talend 版本 7.1.

最近此 REST 服务更改了其 HTTP 服务器库的版本(libmicrohttpd,REST 服务基于 C/C++)。特别是,已从 limicrohttpd 0.9.48 移动到 0.9.70。自从我们进行更改后,ETL 中的集成就开始失败了。我们在 talend 跟踪中看到这样的消息:

--------------------------------------
time=2020-08-05 08:26:01| lvl=INFO | ver=1.0| Inbound Message
----------------------------
ID: 1
Response-Code: 204
Encoding: ISO-8859-1
Content-Type: 
Headers: {Cache-Control=[no-cache, no-store, max-age=0, must-revalidate], connection=[keep-alive], Date=[Wed, 05 Aug 2020 06:26:03 GMT], Expires=[0], fiware-correlator=[894f7ff0-d6e4-11ea-b1bd-fa163ec74401], Pragma=[no-cache], Referrer-Policy=[same-origin], Server=[nginx], Strict-Transport-Security=[max-age=31536000; includeSubdomains;], X-Content-Type-Options=[nosniff], X-Frame-Options=[SAMEORIGIN], X-XSS-Protection=[1; mode=block]}
--------------------------------------
Exception in component tRESTClient_1 (VLCI_ETL_MEDIOAMBIENTE_INSERT_CB)
javax.ws.rs.client.ResponseProcessingException: Problem with reading the data, class org.dom4j.Document, ContentType: */*.
                at org.apache.cxf.jaxrs.impl.ResponseImpl.reportMessageHandlerProblem(ResponseImpl.java:437)
                at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:379)
                at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:314)
                at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:304)
              …

我们仍在调查该问题,但我们怀疑 libmicrohttpd 中引入的其中一项更改可能与之相关。特别是,对于 libmicrohttd 0.9.48(当 ETL 工作时)“Content-Length: 0”header 包含在 204 个响应中。对于 libmicrohttpd 0.9.70(当 ETL 不工作时)这样的“Content-Length: 0” header 不包括在内。

这是一个已知问题吗?我的意思是,如果“Content-Lengh: 0”不包含在 204 响应中,tRESTClient(7.1 版)是否会失败?

请注意,关于 204 响应中 Content-Length 的使用,HTTP 规范非常明确。来自 RFC 7321(据我所知这是 HTTP 的规范标准)section 6.1:

A server MUST NOT send a Content-Length header field in any response with a status code of 1xx (Informational) or 204 (No Content)”

所以如果 tRESTClient 不支持它,那么我理解是 talend 中的一个错误(也许在 post-7.1 版本中解决了?)

非常欢迎对此提出任何反馈!感谢您的关注。

最后,我们似乎通过以下方式解决了问题。

在失败的情况下,组件正在使用此配置:

我们通过以下方式将接受类型从“JSON”更改为“任意”:

现在可以正常使用了。

我的猜测是,对于接受类型“JSON”,组件正在等待响应负载,这在 204 无内容的情况下是有问题的。使用“Any”可消除该限制。

在这种情况下,也许它偶然与 non-standard content-length: 0 header 一起工作......无论如何它有点奇怪,我认为 tRESTClient 应该比这个。也许是 post-7.1 版本中已经修复的行为。

欢迎对此解决方案提出任何反馈或意见。谢谢!