【发布时间】:2018-06-26 06:09:27
【问题描述】:
在使用 Apache httpcore 5 for java 时,AsyncServerRequestHandler 中的 handle() 方法如何将标头添加到响应中?
https://hc.apache.org/httpcomponents-core-5.0.x/examples.html 有几个示例,例如 https://hc.apache.org/httpcomponents-core-5.0.x/httpcore5-h2/examples/org/apache/hc/core5/http/examples/Http2FileServerExample.java,但它们有些密集。
在旧的 httpcore
response.setHeader("Access-Control-Allow-Origin", "*")
但不清楚httpcore 5使用的许多间接层中哪一层是可以访问响应头的层,以及哪个对象具有与setHeader对应的方法。
【问题讨论】: