httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hracek, Petr" <petr.hra...@siemens.com>
Subject RE: Sending data to client
Date Fri, 30 Jan 2009 11:50:09 GMT
Thanks for the question about replacement of ap_*_timeout.

When the ap_soft_timeout and ap_rwrite are called in Apache 1.3
I've never inserted HTML tags like <html><body> etc.
They were inserted automatically?

Is it necessary to include HTML tags to buffer which is sent to the Client side?

And do you know how can I monitored if the date were successfully sent / delivered to 
the client side? All comunication is done over https.

Thank you in advance

regards / S pozdravem
Petr Hráček

-----Original Message-----
From: Graham Leggett [mailto:minfrin@sharp.fm] 
Sent: Friday, January 30, 2009 12:29 PM
To: dev@httpd.apache.org
Subject: Re: Sending data to client

Hracek, Petr wrote:

> I am migrating apache module from version 1.3.41 to version 2.2.3
> All seems to be OK but only one thing remains as not working and I have no idea how to
solve
> it in Apache 2.2.
>  
> In the version 1.3.41 I used to following code for sending data to client:
> ap_soft_timeout ("TEXT MESSAGE",r);
> ap_rwrite(MESSAGE_TO_CLIENT, strlen(MESSAGE_TO_CLIENT),r);
> ap_kill_timeout(r);
>  
> How can send data to client on Apache 2.2?

Apache v2.0 (and v2.2) introduced the concept of an input and an output 
filter stack to handle the problem of reading from and writing to the 
network.

The input filter stack is a chain of code that reads data in from the 
network. Filters in the stack along the way might uncompress the data, 
decrypt the data, or do any of a number of things to the data before 
handing the data to you.

The output filter stack is a chain of code that writes data to the 
network, and is the one you want to care about. The output filter stack 
might encrypt, compress, chunk or otherwise process the data you send, 
and you don't need to know or care how this is done.

The filter stacks solved a long standing problem in Apache 1.3, which if 
you wanted to process data that was entering or leaving the server, you 
couldn't really without hacking away at the core.

So, to come round and actually answer your question, in Apache v2.2, you 
want to write your data to the output filter stack.

The best examples are in the webserver itself. The least confusing 
module to use as an example would probably be the status_handler 
function inside mod_status, which uses ap_rputs() and ap_rvputs() to 
write strings to the network, which sounds like what you are doing.

If you want to have more control over the data you are sending, you can 
call ap_pass_brigade() to "write" some data, in the form of a bucket 
bridge, to the network in your response.

This second option allows you to send any number of things to the 
network, from static areas of memory, to files on disk, in a very 
efficient way. For more information about bucket brigades, read the docs 
for the bucket brigade API in APR:

http://apr.apache.org/docs/apr-util/trunk/group___a_p_r___util___bucket___brigades.html

Regards,
Graham
--

Mime
View raw message