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

Code cleanup in file responses #1769

Merged
merged 2 commits into from
Jan 27, 2020

Conversation

Tronic
Copy link
Member

@Tronic Tronic commented Jan 21, 2020

Avoids ugly hack of earlier commit and cleans up the other code as well.

Minor difference with streaming file response: headers are now sent without opening the file, so any errors will terminate the HTTP connection. Old behaviour was an uncaught exception causing a 500 response to be sent.

Ideally those errors would be handled and proper code (404, 403) be issued if opening the file fails.

@codecov
Copy link

codecov bot commented Jan 21, 2020

Codecov Report

Merging #1769 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1769      +/-   ##
==========================================
- Coverage   91.97%   91.95%   -0.02%     
==========================================
  Files          23       23              
  Lines        2281     2276       -5     
  Branches      426      426              
==========================================
- Hits         2098     2093       -5     
  Misses        142      142              
  Partials       41       41
Impacted Files Coverage Δ
sanic/response.py 98.67% <100%> (-0.05%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bffdb3b...97bb9e0. Read the comment docs.

@Tronic
Copy link
Member Author

Tronic commented Jan 21, 2020

Be damned fixed line lengths, black uglified the code again.

@Tronic Tronic changed the title Code cleanup in file responses WIP: Code cleanup in file responses Jan 23, 2020
Copy link
Member

@yunstanford yunstanford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still WIP ?

@Tronic
Copy link
Member Author

Tronic commented Jan 25, 2020

This can be merged. I'll make another PR if there is further development.

@Tronic Tronic changed the title WIP: Code cleanup in file responses Code cleanup in file responses Jan 25, 2020
@yunstanford yunstanford merged commit dac0514 into sanic-org:master Jan 27, 2020
@Tronic Tronic deleted the file_response_cleanup branch January 27, 2020 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants