无法覆盖 XPages 的 HttpServletResponse 中的 "Connection" header
Cannot override "Connection" header in XPages' HttpServletResponse
在我的 XPage 应用程序中,我想在从一个 XPage 向另一个 XPage 发送 XMLHttpRequest 时保持连接有效。因此,我将 "Connection" header 设置为“keep-alive”。
在 client-side 我有:
xhr=new XMLHttpRequest();
xhr.setRequestHeader("Connection","keep-alive");
在 server-side 上(在响应 XPage 的 afterRenderResponse 事件中)我使用:
response=facesContext.getExternalContext().getResponse();
response.setHeader("Connection","keep-alive");
检查请求和响应时(使用 FireBug),发现请求 header 包含“Connection = keep-alive”(正如预期的那样),但响应 headers 包含“Connection = close”。
有人知道如何覆盖这个 header 吗?
解决方案:在xsp.properties文件集xsp.compress.mode=gzip
中。这等于在 Xsp 属性/页面生成下设置 Compression = "GZip, set content length"
。
说明:我的应用程序使用服务器默认压缩,即gzip-nolength
。当未设置内容长度时,XPages 的响应 (XspHttpServletResponse) 似乎总是将 "Connection" header 设置为 "close"。设置内容长度后,"Connection" header 不再存在,默认情况下保持连接。
在我的 XPage 应用程序中,我想在从一个 XPage 向另一个 XPage 发送 XMLHttpRequest 时保持连接有效。因此,我将 "Connection" header 设置为“keep-alive”。
在 client-side 我有:
xhr=new XMLHttpRequest();
xhr.setRequestHeader("Connection","keep-alive");
在 server-side 上(在响应 XPage 的 afterRenderResponse 事件中)我使用:
response=facesContext.getExternalContext().getResponse();
response.setHeader("Connection","keep-alive");
检查请求和响应时(使用 FireBug),发现请求 header 包含“Connection = keep-alive”(正如预期的那样),但响应 headers 包含“Connection = close”。
有人知道如何覆盖这个 header 吗?
解决方案:在xsp.properties文件集xsp.compress.mode=gzip
中。这等于在 Xsp 属性/页面生成下设置 Compression = "GZip, set content length"
。
说明:我的应用程序使用服务器默认压缩,即gzip-nolength
。当未设置内容长度时,XPages 的响应 (XspHttpServletResponse) 似乎总是将 "Connection" header 设置为 "close"。设置内容长度后,"Connection" header 不再存在,默认情况下保持连接。