Alanxtl commented on code in PR #657:
URL: https://github.com/apache/dubbo-go-pixiu/pull/657#discussion_r2048183283
##########
pkg/common/http/manager.go:
##########
@@ -107,16 +108,88 @@ func (hcm *HttpConnectionManager) handleHTTPRequest(c
*pch.HttpContext) {
//todo timeout
filterChain.OnDecode(c)
hcm.buildTargetResponse(c)
+ //todo: stream resp has to set HTTP Server's WriteTimeout to 0, need to
check it
+ //todo: stream resp ignores OnEncode stage
filterChain.OnEncode(c)
hcm.writeResponse(c)
}
func (hcm *HttpConnectionManager) writeResponse(c *pch.HttpContext) {
if !c.LocalReply() {
- writer := c.Writer
- writer.WriteHeader(c.GetStatusCode())
- if _, err := writer.Write(c.TargetResp.Data); err != nil {
- logger.Errorf("write response error: %s", err)
+ c.Writer.WriteHeader(c.GetStatusCode())
+ if c.TargetResp != nil {
+ switch res := c.TargetResp.(type) {
+ case *client.ByteResponse:
+ _, err := c.Writer.Write(res.Data)
+ if err != nil {
+ logger.Errorf("Write response failed:
%v", err)
+ }
+ case *client.StreamResponse:
+ // create ctx helps goroutine exit
+ ctx, cancel := context.WithCancel(c.Ctx)
+ defer cancel()
+
+ dataCh := make(chan []byte)
+ errCh := make(chan error, 1)
Review Comment:
fixed
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]