We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
只配置了自定义插件apisix-java-plugin-runner,使用request.getVars("status")获取到的响应码为0,期望获取的是200,应该怎么获取正确的响应码?
APISIX version:3.2 apisix-java-plugin-runner version:0.4.0
"plugins": { "ext-plugin-post-resp": { "allow_degradation": true, "conf": [{ "name": "ReceiveResponseFilter", "value": "{"appId":"1000","validate_header":"cookie","rejected_code":"403"}" }] } }
@slf4j @component public class ReceiveResponseFilter implements PluginFilter {
@Override public String name() { return "ReceiveResponseFilter"; } /** * @param request * @param response * @param chain */ @Override public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) { String configStr = request.getConfig(this); Gson gson = new Gson(); Map<String, Object> conf = new HashMap<>(); conf = gson.fromJson(configStr, conf.getClass()); try { String appId = String.valueOf(conf.get("appId")); log.info("ReceiveResponseFilter appId {}", appId); byte[] bodyBytes = request.getBody().getBytes(StandardCharsets.ISO_8859_1); String responseBody = new String(bodyBytes, StandardCharsets.UTF_8); log.info("responseBody----- {}", responseBody); String requestVarsHost = request.getVars("host"); String uri = request.getVars("uri"); String request_method = request.getVars("request_method"); String remote_addr = request.getVars("remote_addr"); String http_cookie = request.getVars("http_cookie"); String status = request.getVars("status"); log.info("requestVars host {}", requestVarsHost); log.info("requestVars uri {}", uri); log.info("requestVars request_method {}", request_method); log.info("requestVars remote_addr {}", remote_addr); log.info("requestVars http_cookie {}", http_cookie); log.info("requestVars status {}", status); Integer upstreamStatusCode = request.getUpstreamStatusCode(); log.info("upstreamStatusCode {}", upstreamStatusCode); } catch (Exception e) { log.info("ReceiveResponseFilter error {}", ExceptionUtil.stacktraceToString(e)); } chain.postFilter(request, response); } @Override public List<String> requiredVars() { List<String> requiredVars = new ArrayList<>(); requiredVars.add("host"); requiredVars.add("uri"); requiredVars.add("request_method"); requiredVars.add("remote_addr"); requiredVars.add("http_cookie"); requiredVars.add("status"); return requiredVars; } @Override public Boolean requiredRespBody() { return true; }
}
requestVars status 0 upstreamStatusCode 13
正常获取请求返回的成功/失败响应码
The text was updated successfully, but these errors were encountered:
@cb123456-user I encountered this issue previous. and fix it: See the comment here: https://github.com/gaoxingliang/apisix-java-plugin-runner/blob/encrypt-response/readme-new.md?plain=1#L9
But the problem here is: I forgot how to fix that. You can try to upgrade the dependency like this:
<groupId>io.github.api7</groupId> <artifactId>A6</artifactId> <version>0.6.1-RELEASE</version>
And what I can confirm is: the code in my repo is working as expected. In the post response code, I also checked the upstream status:
https://github.com/gaoxingliang/apisix-java-plugin-runner/blob/encrypt-response/runner-starter/src/main/java/org/apache/apisix/plugin/runner/filter/EncryptResponseFilter.java#L46
Sorry, something went wrong.
No branches or pull requests
Issue description
只配置了自定义插件apisix-java-plugin-runner,使用request.getVars("status")获取到的响应码为0,期望获取的是200,应该怎么获取正确的响应码?
Environment
APISIX version:3.2
apisix-java-plugin-runner version:0.4.0
plugin config
"plugins": {
"ext-plugin-post-resp": {
"allow_degradation": true,
"conf": [{
"name": "ReceiveResponseFilter",
"value": "{"appId":"1000","validate_header":"cookie","rejected_code":"403"}"
}]
}
}
插件代码
@slf4j
@component
public class ReceiveResponseFilter implements PluginFilter {
}
正常请求结果
requestVars status 0
upstreamStatusCode 13
失败请求结果
requestVars status 0
upstreamStatusCode 13
预期结果
正常获取请求返回的成功/失败响应码
The text was updated successfully, but these errors were encountered: