Skip to content

SetBodyStream closes io.Reader - not idiomatic? #1957

Description

@KernelDeimos

I opened an issue on fiber when I thought something was missing, and eventually found out there was no bug or missing feature but rather very surprising behavior - I passed an io.Reader to c.SendStream (in fiber) and fasthttp actually type-asserts to io.ReadCloser and closes it for me.

This isn't idiomatic right? My understanding was whoever opens a resource is responsible for closing it, which is why we pass io.Reader instead of io.ReadCloser. While it's difficult for me to think of a practical example, in theory someone might not want fasthttp to close the stream.

I'm not pushing for any fix or change, as changing this would introduce regressions at a wide scale; maybe something to consider for a v3 release but mostly I'd really like to know if there is (or can be) a hard rule for this sort of thing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestSuggestion for a new feature or improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions