Skip to content

FP wrapping http body in MaxBytesReader #69

@percivalalb

Description

@percivalalb

https://pkg.go.dev/net/http#MaxBytesReader

closes the underlying reader when its Close method is called.

Is it possible to detect when the body could be implicitly closed like in the below::

res, err := client.Do(req)
if err != nil {
    panic(err)
}

resBody := res.Body

if maxMediaSize > 0 {
    resBody = http.MaxBytesReader(nil, res.Body, maxMediaSize)
}

defer resBody.Close()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions