diff --git a/proxy/mucp/mucp.go b/proxy/mucp/mucp.go index 0b059da3..388aba91 100644 --- a/proxy/mucp/mucp.go +++ b/proxy/mucp/mucp.go @@ -398,7 +398,7 @@ func (p *Proxy) ServeRequest(ctx context.Context, req server.Request, rsp server // set address if available via routes or specific endpoint if len(routes) > 0 { - addresses := toNodes(routes) + addresses = toNodes(routes) opts = append(opts, client.WithAddress(addresses...)) } @@ -489,6 +489,25 @@ func (p *Proxy) serveRequest(ctx context.Context, link client.Client, service, e } defer stream.Close() + // if we receive a grpc stream we have to refire the initial request + if c, ok := req.Codec().(codec.Codec); ok && c.String() == "grpc" { + // get the header from client + hdr := req.Header() + msg := &codec.Message{ + Type: codec.Request, + Header: hdr, + Body: body, + } + + // write the raw request + err = stream.Request().Codec().Write(msg, nil) + if err == io.EOF { + return nil + } else if err != nil { + return err + } + } + // create client request read loop if streaming go readLoop(req, stream)