Forums / General / Download pdf file return "206 - Partial Content" status

Download pdf file return "206 - Partial Content" status

Author Message

Domenico Garozzo

Thursday 07 July 2011 4:25:17 pm

Hi,

i have an article object that have a pdf file as related object. I have added in article full template the code to show the related object.

When i click on link ez show me the link to download file. When i click the link the browser return the 206 status.

eZ version: Community Project 2011.6 (Community Project 2011.6)

php version: 5.2.14

 

Have you an idea?

Thanks.

Domenico

Tomislav Buljević

Friday 08 July 2011 2:36:55 am

Hello Domenico,

Just a quick idea: Have you checked the Rules and Policies for the Anonymous users? Do they have the permission to download your files?

Steven E. Bailey

Friday 08 July 2011 4:10:50 am

206 is partial content... does the status come back instantly or does it take a while?  It could be that your max_execution_time is set lower than the time it is taking to send this pdf.  How big is the pdf anyway?

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Domenico Garozzo

Friday 08 July 2011 3:35:49 pm

First of all, thank you for your answers.

Now the problem is at this link: http://etnaworldtrade.domenicogarozzo.it/Media/Files/Articolo-di-giornale

The file is little and the server return error fastly.

There is a ez publish log file that can i read? Or a php settings to show warning or error?

 

Thank you.

Domenico

Steven E. Bailey

Saturday 09 July 2011 2:13:24 am

Since it goes so fast I'm guessing the server never gets to the file so it's not a size problem.

Your server logs should be where the ErrorLog directive (if there is one) points to in your apache configuration file (or virtual host file) - most of the time it'll be under /var/log/apache2 or /var/log/httpd - but it could be anywhere.  For a server problem this is the best place to look - you may have to tweak the error_reporting directive in your php.ini if you see nothing.

Also, make sure the file exists, is a (valid) pdf, and is readable by the user running your server.  It should be under <ezpublish root>/<VarDir>/storage/original/application.  VarDir is the parameter supplied in the site.ini under [FileSettings].  If you have access to the database you can find the hash.pdf that corresponds with the original filename.pdf.

The ezpublish logs are under <ezpublish root>/var/log but if it's a server problem there probably won't be any relevant errors.  But check anyway.

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Domenico Garozzo

Saturday 09 July 2011 10:51:27 am

In apache log the error is this: [Sat Jul 09 10:37:18 2011] [error] [client 194.28.172.10] malformed header from script. Bad header=; filename=: index.php

Very strange.....

Steven E. Bailey

Sunday 10 July 2011 12:15:07 am

Are your rewrite rules working?

Rewriterule ^/var/storage/.* - [L]
Rewriterule ^/var/[^/]+/storage/.* - [L]

This should keep a request for a file in <VarDir>/storage from going to index.php

To help debug rewrite rule requests (with apache) you can set something like this:

RewriteLog /var/log/apache2/rewrite.log
RewriteLogLevel 1

The RewriteLogLevel can be set anywhere from 1 to 9 but it quickly becomes overwhelming so keep the number low... also it slows the server down and can create large log files so you definitely don't want to forget to turn this off.

Other questions to ask if the above is not the problem:

Is this pdf a valid file?  Does this happen with all pdfs/all storage files?  Did someone remove application/pdf from your mime.types file (assuming you are using apache)?  Is there something custom about your index.php?  Did this use to work with a previous version?

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Douglas Hammond

Sunday 10 July 2011 6:40:02 pm

ezPublish has added some cool features to the latest release to support things like seeking position in videos.

Unfortuanatley it looks like some bugs were introduced too.

IE seems not to be able to download a file suing the new method.  Also there is an error with the file name due to operator precedence.

I have reported this.  take a look at http://issues.ez.no/IssueView.php?Id=18436

I discovered this after upgrading.  Downloads were working in firefox but not in IE.

Steven E. Bailey

Monday 11 July 2011 1:14:06 am

@Douglas - interesting.  But, if it turns out to be this, then it's not working with firefox (3.x or 4.x) either... because that's what I tried to use to download the file above: http://etnaworldtrade.domenicogarozzo.it/Media/Files/Articolo-di-giornale

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Douglas Hammond

Monday 11 July 2011 6:12:47 am

I'm using Firefox 5.  Not sure if that makes a difference.

Either way the two issues as explained are the file name ends up blank because of the string concatenation with a ternary operator(see http://stackoverflow.com/questions/1317383/ternary-operator-and-string-concatenation-quirk for an example), and it always does partial file handling because of the wrong operator used to test if a start position and the file length exist.

Domenico Garozzo

Monday 11 July 2011 6:49:11 am

"

Are your rewrite rules working?

Rewriterule ^/var/storage/.* - [L]
Rewriterule ^/var/[^/]+/storage/.* - [L]

"

Hi Steven, (sorry for the inappropriate. I don't want click the button.)

my .htaccess file content is:

DirectoryIndex index.php
RewriteEngine On
RewriteRule ^api/ index_rest.php [L]
RewriteRule ^index_rest\.php - [L]
RewriteRule ^([^/]+/)?content/treemenu.* index_treemenu\.php [L]
RewriteRule ^var/([^/]+/)?storage/images(-versioned)?/.* - [L]
RewriteRule ^var/([^/]+/)?cache/(texttoimage|public)/.* - [L]
RewriteRule ^design/[^/]+/(stylesheets|images|javascript)/.* - [L]
RewriteRule ^share/icons/.* - [L]
RewriteRule ^extension/[^/]+/design/[^/]+/(stylesheets|flash|images|lib|javascripts?)/.* - [L]
RewriteRule ^packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
RewriteRule ^packages/styles/.+/thumbnail/.* - [L]
RewriteRule ^var/storage/packages/.* - [L]

RewriteRule ^favicon\.ico - [L]
RewriteRule ^design/standard/images/favicon\.ico - [L]

RewriteRule ^robots\.txt - [L]

RewriteRule ^w3c/p3p\.xml - [L]
RewriteRule .* index\.php

 

The file is a valid PDF.
I can open it with Preview.

Steven E. Bailey

Monday 11 July 2011 6:57:04 am

@Douglas - Doesn't work for me with firefox5 either  - does the file on this page work for you with your version of firefox5? http://etnaworldtrade.domenicogarozzo.it/Media/Files/Articolo-di-giornale

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Douglas Hammond

Monday 11 July 2011 7:12:20 am

Does not work.  This looks identical to what I had before I fixed the ezFile class.

Did you apply the patch in the issue I listed?

Add a line to ezFile just before line 253

$tempString = ( $overrideFilename !== false ) ? "; filename={$overrideFilename}" : '';

Then use xdebug to see what $tempString is.

You will find is is something like "; filename="

This is an invalid header.

You need to change line 256 to:

(( $overrideFilename !== false ) ? "; filename={$overrideFilename}" : '')

Note the surrounding ()

Also on line 260 make it:

if ( $startOffset !== 0 )

Or it will always use partial handling as ezfilepassthroughhandler(i thing that was the name) always passes a filesize which will make it use the partial handling.

Domenico Garozzo

Monday 11 July 2011 3:41:50 pm

"

ezPublish has added some cool features to the latest release to support things like seeking position in videos.

Unfortuanatley it looks like some bugs were introduced too.

IE seems not to be able to download a file suing the new method.  Also there is an error with the file name due to operator precedence.

I have reported this.  take a look at http://issues.ez.no/IssueView.php?Id=18436

I discovered this after upgrading.  Downloads were working in firefox but not in IE.

"

Thank you very much for this solution. Now download go!

Thank you very much at everybody for the support.

Have a nice day.

Domenico

eZ debug

Timing: Jan 17 2025 23:38:03
Script start
Timing: Jan 17 2025 23:38:03
Module start 'content'
Timing: Jan 17 2025 23:38:04
Module end 'content'
Timing: Jan 17 2025 23:38:05
Script end

Main resources:

Total runtime1.2035 sec
Peak memory usage4,096.0000 KB
Database Queries236

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 590.1563180.8281
Module start 'content' 0.00621.0903 770.9844784.9922
Module end 'content' 1.09650.1069 1,555.9766361.3125
Script end 1.2034  1,917.2891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.3254210.0002
Check MTime0.00160.1321210.0001
Mysql Total
Database connection0.00070.061010.0007
Mysqli_queries1.099991.38962360.0047
Looping result0.00230.18792340.0000
Template Total1.180698.120.5903
Template load0.00230.194120.0012
Template processing1.178297.900820.5891
Template load and register function0.00010.009310.0001
states
state_id_array0.00070.060910.0007
state_identifier_array0.00060.050920.0003
Override
Cache load0.00230.19001260.0000
Sytem overhead
Fetch class attribute can translate value0.00130.106450.0003
Fetch class attribute name0.00130.1046170.0001
XML
Image XML parsing0.00340.280450.0007
class_abstraction
Instantiating content class attribute0.00000.0034250.0000
General
dbfile0.00380.3147400.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
11content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
14content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
26content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
2content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 67
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs