andelf / andelf/go-curl

Perform() hangs when passing in false to WRITEFUNCTION

未關閉
#56 10 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Go
星號
519
分支
139
PR 合併指標
30 天內沒有已合併 PR

描述

Hi,

I was trying to write data returned into a buffer. However if there is a write error in the call back function then it looks like easy.Perform() hangs and never returns.

`b := NewBuffer(make([]byte, 0, 10), capacity)

// Callback function to save data instead of redirecting it into stdout.
writeToBufferFunc := func(buf []byte, userdata interface{}) bool {
if silent == false {
_, err := b.Write([]byte(buf))
if err != nil {
return false
}
}
return true
}
// the above callback function returns false in my case. Since there is a write error
// I am trying to restrict the buffer capacity.

this.myCurl.Setopt(curl.OPT_WRITEFUNCTION, writeToBufferFunc)

this.myCurl.Setopt(curl.OPT_WRITEDATA, b.mybuf)
logging.Infof("\n\n ---------------- Reaches here \n")

// Hangs here and never reaches 2.
if err := this.myCurl.Perform(); err != nil {
logging.Infof("\n\n ---------------- Reaches here 2 \n")
if show_error == true {
return nil, err
} else {
return nil, nil
}
}
`

Is there a way for me to fix this in my code ?

Thanks
Isha

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。