how close a connection from server side that created by ajax from client side
- by saeid
I have this sample php code:
<?php
function response($a) {
@ob_end_clean();
header("Connection: close");
ob_start();
echo $a;
$length = ob_get_length();
header("Content-Length: $length");
ob_end_flush();
flush();
}
response("test1");
sleep(5);
echo "test2";
?>
now I make a connection to server from client by ajax.
now I want to server only send "test1" to me and then close the connection.
but connection not closed and wait 5 seconds and send me "test1 test2" !!
this is response headers from server to me :
X-Powered-By: PHP/5.3.27
Connection: close
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Cache-Control: private, no-cache, no-store, ------revalidate, no-transform
Transfer-Encoding: chunked
Content-Type: text/html
in response headers I do not see Content-Length header. is problem for this ??
or if not what I must do now for solving problem ??