You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/12/09 03:15:29 UTC

[GitHub] [servicecomb-java-chassis] wolfgang520 opened a new issue #2111: 单微服务的接口测试需要Mock,部分接口返回 201 返回码。但是在servicecomb中好像没办法设置返回码,400+的错误码可以用exception来处理,可是201这样的正常码怎么处理

wolfgang520 opened a new issue #2111:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2111


   尝试了 filter 中  获取responseEx 并设置也不行, 上下文又取不到。


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] wolfgang520 commented on issue #2111: 单微服务的接口测试需要Mock,部分接口返回 201 返回码。但是在servicecomb中好像没办法设置返回码,400+的错误码可以用exception来处理,可是201这样的正常码怎么处理

Posted by GitBox <gi...@apache.org>.
wolfgang520 commented on issue #2111:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2111#issuecomment-741578076


   有没有不通过注解的方式,在代码里设置 201 返回码


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2111: 单微服务的接口测试需要Mock,部分接口返回 201 返回码。但是在servicecomb中好像没办法设置返回码,400+的错误码可以用exception来处理,可是201这样的正常码怎么处理

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2111:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2111#issuecomment-742181418


   都调试到这么深入的环节了,可以继续跟踪一下。 这种情况的问题不是自己尝试下, 是解答不了你的。


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2111: 单微服务的接口测试需要Mock,部分接口返回 201 返回码。但是在servicecomb中好像没办法设置返回码,400+的错误码可以用exception来处理,可是201这样的正常码怎么处理

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2111:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2111#issuecomment-741581555


   ```
     public ResponseEntity<Date> responseEntity(InvocationContext c1, Date date) {
       HttpHeaders headers = new HttpHeaders();
       headers.add("h1", "h1v " + c1.getContext().toString());
   
       InvocationContext c2 = ContextUtils.getInvocationContext();
       headers.add("h2", "h2v " + c2.getContext().toString());
   
       return new ResponseEntity<>(date, headers, HttpStatus.ACCEPTED);
     }
   ```
   
   试试这个。 


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2111: 单微服务的接口测试需要Mock,部分接口返回 201 返回码。但是在servicecomb中好像没办法设置返回码,400+的错误码可以用exception来处理,可是201这样的正常码怎么处理

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2111:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2111#issuecomment-741507434


   看看这里 : https://docs.servicecomb.io/java-chassis/zh_CN/general-development/error-handling/


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] wolfgang520 commented on issue #2111: 单微服务的接口测试需要Mock,部分接口返回 201 返回码。但是在servicecomb中好像没办法设置返回码,400+的错误码可以用exception来处理,可是201这样的正常码怎么处理

Posted by GitBox <gi...@apache.org>.
wolfgang520 commented on issue #2111:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2111#issuecomment-742177656


   跟踪到 AbstractRestInvocation.java 中 sendResponse 里 response对象的status都还是201
   但是最后客户端收到的status还是200, 在sendResponse 之后还有什么地方会修改status ?
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org