projects
/
brisk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
stat-day.php bug fixed and some log added
[brisk.git]
/
web
/
Obj
/
sac-a-push.phh
diff --git
a/web/Obj/sac-a-push.phh
b/web/Obj/sac-a-push.phh
index
502670d
..
973e012
100644
(file)
--- a/
web/Obj/sac-a-push.phh
+++ b/
web/Obj/sac-a-push.phh
@@
-221,6
+221,14
@@
function headers_render($header, $len)
}
else if (isset($header['HTTP-Response'])) {
$s = sprintf("HTTP/1.1 %s\r\n", $header['HTTP-Response']);
}
else if (isset($header['HTTP-Response'])) {
$s = sprintf("HTTP/1.1 %s\r\n", $header['HTTP-Response']);
+ foreach($header as $key => $value) {
+ if (strtolower($key) == "http-response")
+ continue;
+ $s .= sprintf("%s: %s\r\n", $key, $value);
+ }
+ if ($len >= 0) {
+ $s .= sprintf("Content-Length: %ld\r\n", $len);
+ }
}
else {
$s = "HTTP/1.1 200 OK\r\n";
}
else {
$s = "HTTP/1.1 200 OK\r\n";
@@
-701,7
+709,7
@@
class Sac_a_push {
if ($buf == FALSE || mb_strlen($buf, "ASCII") == 0) {
// close socket case
if ($buf == FALSE) {
if ($buf == FALSE || mb_strlen($buf, "ASCII") == 0) {
// close socket case
if ($buf == FALSE) {
- printf("
ERROR READING
\n");
+ printf("
INFO: read return false
\n");
}
if ($sock === $this->list) {
printf("Arrivati %d bytes da list\n", mb_strlen($buf, "ASCII"));
}
if ($sock === $this->list) {
printf("Arrivati %d bytes da list\n", mb_strlen($buf, "ASCII"));
@@
-716,6
+724,10
@@
class Sac_a_push {
if (isset($this->s2u[$id])) {
// $user_a[$s2u[$id]]->disable();
if ($this->s2u[$id]->rd_socket_get() != NULL) {
if (isset($this->s2u[$id])) {
// $user_a[$s2u[$id]]->disable();
if ($this->s2u[$id]->rd_socket_get() != NULL) {
+ // try to send close frame (for websocket)
+ $clo = $this->s2u[$id]->stream_close();
+ $clo_l = mb_strlen($clo, "ASCII");
+ @fwrite($sock, $clo, $clo_l);
$this->s2u[$id]->rd_socket_set(NULL);
}
unset($this->s2u[$id]);
$this->s2u[$id]->rd_socket_set(NULL);
}
unset($this->s2u[$id]);
@@
-744,7
+756,7
@@
class Sac_a_push {
global_dump();
}
global_dump();
}
- else if ($line == "shutdown") {
+ else if ($line == "shutdown"
|| $line == "sd"
) {
if ($this->app->dump_data()) {
return(0);
}
if ($this->app->dump_data()) {
return(0);
}
@@
-849,7
+861,7
@@
class Sac_a_push {
// echo "SPIA: [".substr($response, 0, 60)."...]\n";
// echo "SPIA: [".$response."]\n";
$response_l = mb_strlen($response, "ASCII");
// echo "SPIA: [".substr($response, 0, 60)."...]\n";
// echo "SPIA: [".$response."]\n";
$response_l = mb_strlen($response, "ASCII");
- $wret = @fwrite($sock, $response);
+ $wret = @fwrite($sock, $response
, $response_l
);
if ($wret < $response_l) {
printf("TROUBLE WITH FWRITE: %d\n", $wret);
$user->rd_cache_set(mb_substr($response, $wret, $response_l - $wret, "ASCII"));
if ($wret < $response_l) {
printf("TROUBLE WITH FWRITE: %d\n", $wret);
$user->rd_cache_set(mb_substr($response, $wret, $response_l - $wret, "ASCII"));
@@
-868,6
+880,9
@@
class Sac_a_push {
}
unset($this->socks[$id]);
unset($this->s2u[$id]);
}
unset($this->socks[$id]);
unset($this->s2u[$id]);
+ $clo = $user->stream_close();
+ $clo_l = mb_strlen($clo, "ASCII");
+ @fwrite($sock, $clo, $clo_l);
fclose($sock);
printf("CLOSE ON LOOP\n");
}
fclose($sock);
printf("CLOSE ON LOOP\n");
}