beginnerWJC commented on issue #189:
URL:
https://github.com/apache/apisix-java-plugin-runner/issues/189#issuecomment-1223955976
我的测试postFilter代码
package org.apache.apisix.plugin.runner.filter;
import java.util.Map;
import org.apache.apisix.plugin.runner.PostRequest;
import org.apache.apisix.plugin.runner.PostResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
@Component
public class TestPostFilter implements PluginFilter {
private final Logger logger =
LoggerFactory.getLogger(TestPostFilter.class);
@Override
public String name() {
return "TestPostFilter";
}
@Override
public void postFilter(PostRequest request, PostResponse response,
PluginFilterChain chain) {
logger.info("TestPostFilter插件开始执行!");
Map<String, String> headersMap = request.getUpstreamHeaders();
logger.info("上游返回的headers:{}",JSON.toJSONString(headersMap));
int statusCode = request.getUpstreamStatusCode();
logger.info("上游返回的状态码为:{}",statusCode);
response.setHeader("apisix", "TestPostFilter");
chain.postFilter(request, response);
}
}
通过apisix dashboard配置路由一个http返回值是204并且没有返回体的接口

然后测试调用,发现上游的接口返回204时会请求两次
由于我测试代理的是登出接口,第一次是204,第二次由于已经登出过了就变成401了,导致我发现了这个问题。



然后在本地把登出接口http返回码改成200就正常了,只请求了一次


这个是我完整的复现过程了
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]