-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Determine if Response body is populated #1216
Comments
This is definitely something that we're interested in, see #1164 for some more comments and exploration. As for your case, are you interested in whether some user has set a body, or whether there is body coming from the socket? The former could maybe be determined today, that depends on the specific |
Thanks for the link to #1164 @seanmonstar that was interesting background reading. Currently I am most interested in determining if another part of the application has set a The concept is that when a For example adding JSON to the Hopefully that makes sense, little bit of weird one to explain, happy to provide a code example if that would help. |
Ah, so would it be safe to say you have a much more localized desire, than the larger scope of that issue I linked? It seems there is |
#1164 is certainly more advanced than what I need right now.
|
Hey @seanmonstar, apologies, this fell off my radar for a short period. Are you happy for me to create a PR for the functionality discussed above or would you prefer to handle within some other work you have on the go? |
I'm concerned that we want to move the Option out, and letting the Body type itself be an option or something. If so, then adding another method with the Option hardcoded feels wrong. But really, it feels like a breaking change to remove the Option anyways, and so maybe we may as well have the accessors for now, and just know they will have a type change in 0.12... |
Thanks, have submitted #1244 noting potential change of api in the future. |
I was looking through the api provided for
Response
for a way to determine ifbody
has been populated (or not) by some other part of the application. I can't immediately see a way to do this however.I note that
body
is anOption
per https://github.com/hyperium/hyper/blob/master/src/http/response.rs#L15 so simply being able to accessOption::is_some
would suit my use case.Alternatively
Response
could be extended with abool
that could be used to indicate by application code that the current response is considered to be 'committed' and probably should not be further altered.I'd be happy to provide a PR for either (or both) but I wanted to find out if this would be palatable before proceeding.
The text was updated successfully, but these errors were encountered: