You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2021/12/20 12:12:33 UTC

[GitHub] [incubator-brpc] yangyi04 opened a new issue #1647: brpc不支持Content-Type=application/octet-stream的请求

yangyi04 opened a new issue #1647:
URL: https://github.com/apache/incubator-brpc/issues/1647


   **Describe the bug (描述bug)**
   我们在用brpc提供在线服务的时候遇到了个问题:
   客户发来的请求类型是Content-Type=application/octet-stream的protobuf,我们在解析的时候发生了400 Bad Request的错误,x-bd-error-code: 1003。err_str:Fail to parse http body as XXX, Invalid json format
   ![image](https://user-images.githubusercontent.com/96422747/146764871-28f7991f-dd9d-4faa-8a66-2b2717046384.png)
   
   
   **To Reproduce (复现方法)**
   我查看了一下brpc的代码逻辑,brpc内部只认为proto、x-protobuf、grpc开头的content-type是proto,其他情况会强制转换成json而导致报错。
   ![image](https://user-images.githubusercontent.com/96422747/146765006-adb98e38-be66-4e15-93d0-288a5f7646d5.png)
   
   
   
   **Expected behavior (期望行为)**
   想问一下有没有支持Content-Type=application/octet-stream的办法?
   
   **Versions (各种版本)**
   OS:Ubuntu 18.04
   Compiler: gcc 7.5
   brpc: v1.0.0
   protobuf: 3
   
   **Additional context/screenshots (更多上下文/截图)**
   
   


-- 
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: dev-unsubscribe@brpc.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] wwbmmm commented on issue #1647: brpc不支持Content-Type=application/octet-stream的请求

Posted by GitBox <gi...@apache.org>.
wwbmmm commented on issue #1647:
URL: https://github.com/apache/incubator-brpc/issues/1647#issuecomment-998615323


   你可以定义一个空proto message,这样brpc就不会对请求body进行解析,然后你可以自己在代码里通过 cntl->request_attachment()获取到body,然后自己解析成pb对象。


-- 
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: dev-unsubscribe@brpc.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] yangyi04 commented on issue #1647: brpc不支持Content-Type=application/octet-stream的请求

Posted by GitBox <gi...@apache.org>.
yangyi04 commented on issue #1647:
URL: https://github.com/apache/incubator-brpc/issues/1647#issuecomment-998585275


   是不是我的使用方式不对?我这边是proto文件定义了request message,服务函数的输入就是这个request message,然后让brpc把请求内容转化成proto。但是这里认为请求不是proto就转换成json才报错。
   有没有什么办法可以跳过brpc的转换,自己来处理请求的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: dev-unsubscribe@brpc.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org