Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Proposal PipeReader ReadAsync could take an expected size #2220

Closed
Drawaes opened this issue Jan 27, 2020 · 4 comments
Closed

API Proposal PipeReader ReadAsync could take an expected size #2220

Drawaes opened this issue Jan 27, 2020 · 4 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.IO.Pipelines
Milestone

Comments

@Drawaes
Copy link
Contributor

Drawaes commented Jan 27, 2020

Because the flow is inverted with pipelines there is less understanding at the lower levels of the expected data. Often the application protocols have an idea (or if no the application protocol at least the intermediate ones).

For instance in Tls if I only get a partial frame, I know the size of the rest of the frame. Rather than having to loop over and over on ReadAsync() if I haven't got enough yet it would be good to be able to call

var result = await ReadAsync(expectedSize : 40)

and it not return until the connection closes/dies/or there are enough bytes to fill that amount.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Jan 27, 2020
@MihaZupan MihaZupan added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Jan 27, 2020
@AlgorithmsAreCool
Copy link
Contributor

I think this can be done in an extension method right?. It would just be a loop that that calls Advance(Buffer.Start, Buffer.End) until Buffer.Length exceeds expected size or until ReadResult.IsCompleted returns as true.

It would probably be pretty useful.

@Drawaes
Copy link
Contributor Author

Drawaes commented Jan 27, 2020

It could be, and that might be the first iteration but you might never call the ReadAsync continuation of there isn't enough data as well, saving a whole lot of code from running.

@ahsonkhan
Copy link
Member

@maryamariyan - the bot didn't label this issue.

@BrennanConroy BrennanConroy added this to the Future milestone Jul 8, 2020
@halter73 halter73 removed the untriaged New issue has not been triaged by the area owner label Jul 8, 2020
@davidfowl
Copy link
Member

davidfowl commented May 3, 2021

Fixed in #51979. Dupe of #25063

@ghost ghost locked as resolved and limited conversation to collaborators Jun 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.IO.Pipelines
Projects
None yet
Development

No branches or pull requests

8 participants