I am writing a service that sends data as a response, to a client.
I am sending text (PLAIN ASCII) data, but I want to compress the data first (uzing any of the standard compression routines), and then send the compressed data back to the server, using the header() function etc.
I am relatively new to PHP so having gathered the data, I know need to know how I can send the (compressed) data in an HTTP response to the user
This is the pseudocode of what I have so far:
<?php
function createResponse($args)
{
if ( ($data = fetch_data($args)) !== NULL)
{
/* Assumption is that $data is a string consisting of comma separated
values (for the columns) and each "row" is sepeated by a CRLF
so $data looks like this:
18-Oct-2009, 100.2, -10.5, 15.66, 34.2, 99.2, 88.2, 'c', 'it1', 1000342\r\n
19-Oct-2009, -33.72, 47.5, 24.76, 8.2, 89.2, 88.2, 'c', 'it2', 304342\r\n
etc ..
*/
//1. OPTIONAL - need to encrypt $data here (how?)
//2. Need to compress (encrypted?) $data here (how?)
//3. Need to send HTTP Status 200 OK and mime/type (zip/compresed here)
//4. Need to send data
}
else
{
//5. Need to send HTTP error code (say 404) here
}
}
?>
Can any experienced PHP coders out there tell me which statements to use for 1 -5 above ?