473,802 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Chunked encoding with php+apache2

I'm trying to figure out how to enable chunked encoding with php over
apache2 for a particular page. My php/apache combination definitely
supports chunked encoding, because a page which calls only phpinfo()
uses it. On the other hand, pages without phpinfo() don't get sent with
chunked encoding (content-length is used instead). Does anyone know
how to specifically enable chunked encoding for a given page?
Thanks,
Jon

Jul 17 '05 #1
7 16823
on 02/02/2005 11:51 PM jo************@ gmail.com said the following:
I'm trying to figure out how to enable chunked encoding with php over
apache2 for a particular page. My php/apache combination definitely
supports chunked encoding, because a page which calls only phpinfo()
uses it. On the other hand, pages without phpinfo() don't get sent with
chunked encoding (content-length is used instead). Does anyone know
how to specifically enable chunked encoding for a given page?


Why do you want to force chunked encoding on pages that are not
generated dynamically?

Chunked encoding is only useful when you do not know in advance the page
size.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #2
> Why do you want to force chunked encoding on pages that are not
generated dynamically?

Chunked encoding is only useful when you do not know in advance the page size.


The pages *are* created dynamically -- they're written in php, not
plain html. The top part of the page is generated quickly, but the
last part of the page is not generated until after a lengthy operation,
which takes from 5-10 seconds. I need the top part of the page to
display quickly, and then display the last bit later, when it's finally
available. It seems to me that enabling chunked encoding, and flushing
the output at appropriate times is the best (only?) way to accomplish
this (without resorting to frames or complex Javascript). But extensive
Google and documentation searching has yielded nothing for me, so far,
as how to enable it.

Jul 17 '05 #3
jo************@ gmail.com wrote:
The pages *are* created dynamically -- they're written in php [snip] But extensive Google and documentation searching has yielded nothing
for me, so far, as how to enable it.


But if a content-length header gets sent (like you suggest in the OP),
something (either php or apache) is buffering output.

Don't know of any ready made/easy way to turn on chunks. But you could
write an outputbuffer handler that does (but you'd still be at mercy of
Apaches buffering (and the client UAs buffering techniques)).

Jul 17 '05 #4
> Don't know of any ready made/easy way to turn on chunks. But you
could
write an outputbuffer handler that does (but you'd still be at mercy of Apaches buffering (and the client UAs buffering techniques)).


Thanks for the suggestion -- I actually tried that exact thing, but the
content-length was still being sent along, in addition to the chunked
encoding header that I manually added, via the header() function. If
there was a way to control exactly which headers are sent, (i.e.
suppress content-length from being sent) than this method would work,
but I don't know if that's possible.

Jul 17 '05 #5
>If there was a way to control exactly which headers are sent,
(i.e. suppress content-length from being sent) than this
method would work, but I don't know if that's possible.


....plus I'd need to find a way to disable buffering of the entire
output. There's more to it than just disabling headers, I should have
mentioned.

Jul 17 '05 #6
<jo************ @gmail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
I'm trying to figure out how to enable chunked encoding with php over
apache2 for a particular page. My php/apache combination definitely
supports chunked encoding, because a page which calls only phpinfo()
uses it. On the other hand, pages without phpinfo() don't get sent with
chunked encoding (content-length is used instead). Does anyone know
how to specifically enable chunked encoding for a given page?
Thanks,
Jon


Chunking doesn't happen if a content-length header is present. From the
source code:

if ((r->connection->keepalive != AP_CONN_CLOSE)
&& ((r->status == HTTP_NOT_MODIFI ED)
|| (r->status == HTTP_NO_CONTENT )
|| r->header_only
|| apr_table_get(r->headers_out, "Content-Length")
|| ap_find_last_to ken(r->pool,
apr_table_get(r->headers_out,
"Transfer-Encoding"),
"chunked")
|| ((r->proto_num >= HTTP_VERSION(1, 1))
&& (r->chunked = 1))) /* THIS CODE IS CORRECT, see above. */

The variable chunked would not get set if any of the previous conditions are
true. One of them being the presencce of a content-length header. Another,
which might make you scratch your head, is the presence of
"Thansfer-encoding: chunked".

The Apache 2 output filter will automatically add a content-length header if
it sees an end-of-stream marker AND nothing has been sent yet. From the
source code:

if (ctx->data_sent == 0 && eos) {
ap_set_content_ length(r, r->bytes_sent);
}

If PHP passes any data down to Apache before it sends EOS, then chunking
happens. PHP uses a output buffer of 4096 bytes by default. Any page smaller
than that will not get chunked.
Jul 17 '05 #7
> Chunking doesn't happen if a content-length header is present.
From the source code:


Thanks very much for the help -- the apparent behavior makes a lot more
sense now.

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1355
by: voigt Lander | last post by:
How come on the PHP site under the instructions for configuring PHP with Apache 2 http://ca2.php.net/install.apache2 it says , in somewhat stinted English... " Do not use Apache 2.0 and PHP in a production environment neither on Unix nor on Windows."
27
3135
by: Mxsmanic | last post by:
How can I combine SSI, CGI, and PHP in Apache 2.x? I keep reading that this can be done, but I haven't found any examples of the actual configuration required to do it. What I want to do is: 1. Either pull the page from a file or generate it with a CGI program (depending on the individual URL, as usual). 2. Run the output from (1) above through the includes module so that SSI
2
14170
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip Smarty-2.6.7.tar.gz on a system running WindowsXP SP2. Apache and PHP tested out fine. After adding Smarty, I ran the following http://localhost/testphp.php
3
1987
by: kamlai | last post by:
I'm using PHP + apache2 in Linux platform. I found that the upload_max_filesize has only 2M. I want to increase this limit but I don't know where can I set it. I'm using Linux so I don't have php.ini file. Please help. Thanks.
3
18331
by: Joseph S. | last post by:
Hi, I am trying to install PHP 5.0.4 on Apache 2.0.54 on WinXP Pro SP2 as a cgi binary. Apache2 directory is c:/Apache2 htdocs is c:/Apache2/htdocs php is installed in c:/php This contains php.ini, php-cgi.exe and php5ts.dll and other files required for the module method of php installation are also present,
1
2158
by: Schraalhans Keukenmeester | last post by:
A plethora of articles on building PHP & Apache1 statically exist on the web. However I have not been able to find a similar document on a static compilation of PHP in an Apache2 executable. I know using a modular (DSO) approach has gained popularity and is considered 'the way forward' according to many, yet I'd still like to build a monolithic version for a box I am configuring. Is it all all possible with the later versions of...
1
1906
by: paulsendave | last post by:
What a mix! Whilst I grep around for the first set of problems, I thought I'd ask any generous members of this PHP community for clues... I've started by trying out the instructions at: http://dan.drydog.com/apache2php.html Got this out of the make: -----------------------------------------------------------------------------------------------
1
5855
by: Kesavan | last post by:
I install apache2 in /usr/local/apache2 and install php5 by ./configure --with-apxs2=/usr/local/apache2/bin/ apxs PHP is successfully installed in my system. But now my .php files inside /usr/local/apache2/htdocs doesn't get phrased. When I run suse-10-2:/home/kesavan # php info.php
39
5878
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f ISO-8859-1 -t UTF-8 mydb.sql mydb_utf8.sql mysqlCREATE DATABASE mydb_utf8 CHARACTER SET utf8 COLLATE utf8_general_ci;
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10305
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.