You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "rongxianjie (via GitHub)" <gi...@apache.org> on 2023/03/03 09:12:47 UTC
[GitHub] [apisix-java-plugin-runner] rongxianjie opened a new issue, #232: request help: i want to rewrite the response and then return to the client
rongxianjie opened a new issue, #232:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/232
### Issue description
I want to get the upstream response content in the plugin for processing and then return to the client, but it return null
This is how the class is handled:
@Override
public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) {
log.warn("ClientAuthenticationFilter is running");
log.warn("status:{}", request.getUpstreamStatusCode());
// get the upstream response body
String responseBody = request.getBody();
ResultData<ActivityLoginUser> resultData = JsonUtils.json2Bean(responseBody , ResultData.class);
ResultData<AuthUserVo> authResult = new ResultData<>();
authResult.setCode(resultData.getCode());
authResult.setMessage(resultData.getMessage());
if(ObjectUtils.isNotEmpty(resultData.getData())){
AuthUserVo authUserVo = processAuthResult(resultData.getData());
authResult.setData(authUserVo);
}
response.setBody(JsonUtils.bean2Json(authResult));
chain.postFilter(request, response);
}
java.lang.NullPointerException: null
at com.taikang.tlife.activity.apisix.plugins.fliters.ClientAuthenticationFilter.postFilter(ClientAuthenticationFilter.java:85)
### Environment
* your apisix-java-plugin-runner version 0.4.0
--
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: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-java-plugin-runner] tzssangglass commented on issue #232: request help: i want to rewrite the response and then return to the client
Posted by "tzssangglass (via GitHub)" <gi...@apache.org>.
tzssangglass commented on issue #232:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/232#issuecomment-1456411602
whihe line cause the NPE? You need to give detailed steps for reproduction.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-java-plugin-runner] rongxianjie commented on issue #232: request help: i want to rewrite the response and then return to the client
Posted by "rongxianjie (via GitHub)" <gi...@apache.org>.
rongxianjie commented on issue #232:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/232#issuecomment-1455308523
yes, it the plugin of the authentication, the implement fo the plugin is like below:
@Component
public class ClientAuthenticationFilter implements PluginFilter {
@Override
public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) {
log.warn("ClientAuthenticationFilter is running");
log.warn("status:{}", request.getUpstreamStatusCode());
**//i want to get the upstream body, but it cant , the reponseBody is null, so it throws the NullPointerException**
String responseBody = request.getBody();
String authResult = processAuthResult(responseBody );
response.setBody(authResult );
chain.postFilter(request, response);
}
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-java-plugin-runner] tzssangglass commented on issue #232: request help: i want to rewrite the response and then return to the client
Posted by "tzssangglass (via GitHub)" <gi...@apache.org>.
tzssangglass commented on issue #232:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/232#issuecomment-1455136878
> com.taikang.tlife.activity.apisix.plugins.fliters.ClientAuthenticationFilter.postFilter(ClientAuthenticationFilter.java:85)
Is this the NPE in your private code?
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] request help: i want to rewrite the response and then return to the client [apisix-java-plugin-runner]
Posted by "gaoxingliang (via GitHub)" <gi...@apache.org>.
gaoxingliang commented on issue #232:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/232#issuecomment-1822209768
do you add those lines?
```
@Override
public List<String> requiredVars() {
return null;
}
@Override
public Boolean requiredBody() {
return null;
}
```
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-java-plugin-runner] rongxianjie commented on issue #232: request help: i want to rewrite the response and then return to the client
Posted by "rongxianjie (via GitHub)" <gi...@apache.org>.
rongxianjie commented on issue #232:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/232#issuecomment-1455307731
yes, it the plugin of the authentication, the implement fo the plugin is like below:
@Component
public class ClientAuthenticationFilter implements PluginFilter {
@Override
public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) {
log.warn("ClientAuthenticationFilter is running");
log.warn("status:{}", request.getUpstreamStatusCode());
**//i want to get the upstream body, but it cant , the reponseBody is null, so it throws the NullPointerException**
String responseBody = request.getBody();
String authResult = processAuthResult(responseBody );
response.setBody(authResult );
chain.postFilter(request, response);
}
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-java-plugin-runner] tzssangglass commented on issue #232: request help: i want to rewrite the response and then return to the client
Posted by "tzssangglass (via GitHub)" <gi...@apache.org>.
tzssangglass commented on issue #232:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/232#issuecomment-1464032605
a good reproduct describtion like: https://github.com/apache/apisix-java-plugin-runner/issues/189#issuecomment-1226756930
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-java-plugin-runner] 108825446 commented on issue #232: request help: i want to rewrite the response and then return to the client
Posted by "108825446 (via GitHub)" <gi...@apache.org>.
108825446 commented on issue #232:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/232#issuecomment-1461436298
The line String responseBody = request.getBody();
the responseBody is null, when process it in processAuthResult, it throws NullPointerException.
I want to know how to get the upstream reponse content. because the " request.getBody()" cant get the upstream body.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-java-plugin-runner] tzssangglass commented on issue #232: request help: i want to rewrite the response and then return to the client
Posted by "tzssangglass (via GitHub)" <gi...@apache.org>.
tzssangglass commented on issue #232:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/232#issuecomment-1463662227
> the responseBody is null, when process it in processAuthResult, it throws NullPointerException.
You need to give detailed steps for reproduction.
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org