-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Small fix for CHttpRequest to send valid content-length and output #1523
Conversation
Seems you changed something while I was commenting, but still not okay. |
As u can see in issue 1279 i was solving problem with valid content output like in issue 1249, but also in current version ob_get_length() will alwayse be false because of php.ini settings (buffer size), so i think this PR can solve this 2 problems, why do u think they are different? did u see 1279? |
did you understand what #1249 is about? it kills output genereated by Yii::app()->end(). So the code has to stay there. |
Hm, yes, was wrong, so, maybe then leave ob_* near Yii::app()->end() and delete |
You are still replacing CHANGELOG line, please add a new one for your issue. |
@cebe done, is it ok? |
@cebe can u merge it, so i can use it in current master branch? |
@Ragazzo will merge it when I find time to check it. |
@@ -17,6 +17,7 @@ Version 1.1.13 work in progress | |||
- Bug #1181: Fixed can read but not save binary data e.g. BYTEA on PostgreSQL (karmakaze) | |||
- Bug #1212: Added missing .gitignore files to the application generated by WebAppCommand (resurtm) | |||
- Bug #1249: CHttpRequest::sendFile() outputs malformed file content in some specific circumstances (andyhu) | |||
- Bug #1279: CHttpRequest::sendFile() fixed valid content-header send (Ragazzo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to descibe it like CHttpRequest::sendFile() now always sends valid content-header
.
@samdark now ok. hm, is it wrong that "push" to my "repo" was displayed here, i am talking about "b80f229"? |
It's expected. The branch you've pull-requested is tracked by github so when you'll do any changes these will be in the pull request automatically. |
@samdark just seen that you added the line removed here in b029edc do you remember any details about the problem? Imo it should always send the |
Oh, original code comes from 54a24af#L8L551 I am afraid we can't easily find the reason for the existence of this line. |
Sorry for posting that much. Found the original issue: http://code.google.com/p/yii/issues/detail?id=788 |
I checked this code with the following actions: public function actionDownload()
{
Yii::app()->request->sendFile('testfile.txt', str_repeat('aslkdufzas87dfzaosdlfhjaosdiufza', 32)); // file size 1024
} public function actionDownload()
{
ini_set("zlib.output_compression", "On");
Yii::app()->request->sendFile('testfile.txt', str_repeat('aslkdufzas87dfzaosdlfhjaosdiufza', 32)); // file size 1024
} public function actionDownload()
{
ob_start("ob_gzhandler");
Yii::app()->request->sendFile('testfile.txt', str_repeat('aslkdufzas87dfzaosdlfhjaosdiufza', 32)); // file size 1024
} Checked with PHP 5.3.15 Chrome, Firefox, Opera, IE and Safari all working fine. |
@cebe this is to make sure all buffers are already flushed and no buffering is active. I think to see why it's there you have to either turn on output buffering in php.ini or set your custom handler for it. |
@samdark I did the test with output_buffering On and the last action registers the ob_gzhandler which caused no problems with the Content-Length-Header. I can't reproduce the problem that made |
Check #4 |
I've seen that and what I can tell is that the Content-Length header is fine even when and output handler is enabled. At least for php 5.3 |
Hmm, there should be a reason. @qiangxue http://code.google.com/p/yii/source/detail?r=1822 seems to be your fix. Can you remember how to reproduce it? |
@qiangxue can you comment on this? #1523 (comment) I'd like to have this fixed in 1.1.13 |
I think it's because when there's output_handler, it is possible the output is compressed, and as a result the content length may not be the actual one. |
As I said in this comment: #1523 (comment) I tested all common output handlers and they all give the correct output length. |
If I remember, it was a kind of combination of |
Anyway, if we can't figure out and it works currently with all possible combinations, I think we can fix not sending content-length in general and deal with consequences if there will be any during RC time. |
|
Agree. Better of two evils. |
Small fix for CHttpRequest to send valid content-length and output
Thanks for working on this @Ragazzo! |
@cebe hm, thank you and other core-developers for working on this one, more work was made by them, when discussing this solution. Anyway will do on weekend correct PR about "range-header" that was mentioned here, just learning the w3c docs about correct behavior of handling this situation. |
For more info: issue #1279 and #1249