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

Adds Reponse.has_body. #259

Merged
merged 1 commit into from Jul 8, 2016

Conversation

Projects
None yet
3 participants
@martinth
Copy link

martinth commented Jun 29, 2016

This is a result of the discussion in [https://github.com/Pylons/pyramid/issues/2625](Pyramid issue 2625).

Purpose of this property is to allow users to check if the Response has a body without forcing an evaulation of the underlying app_iter. This is handy if you wan't to create a streaming response where the app_iter itself is lazy (i.e. streams data over a socket) or the app_iter can only read once.

It's pretty much the same code as @bertjwregeer suggested but I added it as property rather than es method because I figured that it's fits better in the overall class design this way. The relevant changes for Pyramid will be done later.

Martin Thurau
Adds Reponse.has_body.
Purpose of this property is to allow users to check if the Response has
a body without forcing an evaulation of the underlying app_iter.
This is handy if you wan't to create a streaming response where the
app_iter itself is lazy (i.e. streams data over a socket) or the app_iter
can only read once.
@bertjwregeer

This comment has been minimized.

Copy link
Member

bertjwregeer commented Jun 29, 2016

👍

@bertjwregeer bertjwregeer added this to the 1.7.0 milestone Jun 29, 2016

@mmerickel

This comment has been minimized.

Copy link
Member

mmerickel commented Jun 29, 2016

This looks great. Just to bikeshed for a quick second... response.has_body could be construed to mean something like whether the status code says it should have a body or not. So I'm just curious if there's a more accurate name for this property that we could come up with. So far all I've got is... is_body_empty?

@martinth

This comment has been minimized.

Copy link

martinth commented Jun 30, 2016

You have a point. It could indeed cause confusion if you only look at the property name (which is something I totally have done in the past). is_body_empty is probably the most obvious choice for an alternative but I don't think it's a bad one.

@bertjwregeer

This comment has been minimized.

Copy link
Member

bertjwregeer commented Jun 30, 2016

I'd be okay with the rename. I could see the confusion happening...

@mmerickel

This comment has been minimized.

Copy link
Member

mmerickel commented Jun 30, 2016

is_body_set ?

@mmerickel

This comment has been minimized.

Copy link
Member

mmerickel commented Jun 30, 2016

I think I'm also fine with has_body. I think it's pretty easy to explain its behavior if there is any confusion.

@bertjwregeer

This comment has been minimized.

Copy link
Member

bertjwregeer commented Jun 30, 2016

There is currently no checking if the user attempts to send a Response with an HTTP code that does not allow for a body. This is something that I may want to change in the future...

I am okay with either one. is_body_set or has_body both work for me. I'll let it simmer for a little bit longer and then go ahead and merge it.

@bertjwregeer bertjwregeer merged commit d7ab300 into Pylons:master Jul 8, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

bertjwregeer added a commit that referenced this pull request Jul 8, 2016

bertjwregeer added a commit that referenced this pull request Jul 8, 2016

Merge branch 'fix/exc.py'
This adds a change to stop WebOb from reading the entire `app_iter` when
using the WebOb HTTP Exceptions.

Closes #259

@pyup-bot pyup-bot referenced this pull request Nov 3, 2017

Closed

Update webob to 1.7.3 #434

@pyup-bot pyup-bot referenced this pull request Jan 26, 2018

Closed

Update webob to 1.7.4 #407

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment