代码拉取完成,页面将自动刷新
package gitaly
import (
"context"
"fmt"
"io"
"net/http"
"strconv"
pb "gitlab.com/gitlab-org/gitaly-proto/go"
"gitlab.com/gitlab-org/gitaly/streamio"
)
type BlobClient struct {
pb.BlobServiceClient
}
func (client *BlobClient) SendBlob(ctx context.Context, w http.ResponseWriter, request *pb.GetBlobRequest) error {
c, err := client.GetBlob(ctx, request)
if err != nil {
return fmt.Errorf("rpc failed: %v", err)
}
firstResponseReceived := false
rr := streamio.NewReader(func() ([]byte, error) {
resp, err := c.Recv()
if !firstResponseReceived && err == nil {
firstResponseReceived = true
w.Header().Set("Content-Length", strconv.FormatInt(resp.GetSize(), 10))
}
return resp.GetData(), err
})
if _, err := io.Copy(w, rr); err != nil {
return fmt.Errorf("copy rpc data: %v", err)
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。