Closed glyh closed 4 months ago
Here's an example code:
func getImage(url string) image.Image { client := resty.New() spew.Dump(url) imageResp, err := client.R().Get(url) spew.Dump(err) spew.Dump(imageResp.StatusCode()) data := imageResp.RawBody() defer data.Close() image, err := jpeg.Decode(data) spew.Dump(err) return image }
I got 200 as return code with an jpeg url, but decoding throws error: (*errors.errorString)(0xda6fa0)(http2: response body closed)
With go's builtin http module, it works, however
imageResp, _ := client.Get(imageUrl) data := imageResp.Body defer data.Close() image, _ := jpeg.Decode(data)
Related: I posted this originally on discord https://discord.com/channels/118456055842734083/1219196701886119946/1219196701886119946
https://github.com/go-resty/resty/issues/369 use byte reader instead if not using that option.
Here's an example code:
I got 200 as return code with an jpeg url, but decoding throws error: (*errors.errorString)(0xda6fa0)(http2: response body closed)
With go's builtin http module, it works, however
Related: I posted this originally on discord https://discord.com/channels/118456055842734083/1219196701886119946/1219196701886119946