summaryrefslogtreecommitdiffstats
path: root/php/Attic/examples/sample-sp/assertionConsumer.php
diff options
context:
space:
mode:
authorChristophe Nowicki <cnowicki@easter-eggs.com>2004-09-08 12:56:49 +0000
committerChristophe Nowicki <cnowicki@easter-eggs.com>2004-09-08 12:56:49 +0000
commit789fbb27243b0f0990e8431704099b2713986ba5 (patch)
treeb76e5a12ee59bf3e2c67cd67d79c5609157587ae /php/Attic/examples/sample-sp/assertionConsumer.php
parent5b7353c5f8cc2545aea69b49d2df6c6a32ea03a1 (diff)
SOAP request read problem fixed
SSO is now working much better
Diffstat (limited to 'php/Attic/examples/sample-sp/assertionConsumer.php')
-rw-r--r--php/Attic/examples/sample-sp/assertionConsumer.php40
1 files changed, 31 insertions, 9 deletions
diff --git a/php/Attic/examples/sample-sp/assertionConsumer.php b/php/Attic/examples/sample-sp/assertionConsumer.php
index fc62aec1..575356e0 100644
--- a/php/Attic/examples/sample-sp/assertionConsumer.php
+++ b/php/Attic/examples/sample-sp/assertionConsumer.php
@@ -52,22 +52,44 @@
# PHP 4.3.0 with OpenSSL support required
$fp = fsockopen("ssl://" . $url['host'], $url['port'], $errno, $errstr, 30) or die($errstr ($errno));
+ socket_set_timeout($fp, 10);
fwrite($fp, $soap);
- $ret = fgets($fp);
- if (!preg_match("/^HTTP\/1\\.. 200/i", $ret)) {
- die("Wrong artifact");
- }
+ // header
+ do $header .= fread($fp, 1); while (!preg_match('/\\r\\n\\r\\n$/',$header));
- while (!feof($fp)) {
- $reponse .= @fread($fp, 8192);
+ // chunked encoding
+ if (preg_match('/Transfer\\-Encoding:\\s+chunked\\r\\n/',$header))
+ {
+ do {
+ $byte = '';
+ $chunk_size = '';
+
+ do {
+ $chunk_size .= $byte;
+ $byte = fread($fp, 1);
+ } while ($byte != "\\r");
+
+ fread($fp, 1);
+ $chunk_size = hexdec($chunk_size);
+ $response .= fread($fp, $chunk_size);
+ fread($fp, 2);
+ } while ($chunk_size);
+ }
+ else
+ {
+ if (preg_match('/Content\\-Length:\\s+([0-9]+)\\r\\n/', $header, $matches))
+ $response = fread($fp, $matches[1]);
+ else
+ while (!feof($fp)) $response .= fread($fp, 1024);
}
-
fclose($fp);
- list($header, $body) = preg_split("/(\r\n\r\n|\n\n)/", $reponse, 2);
+ if (!preg_match("/^HTTP\/1\\.. 200/i", $header)) {
+ die("Wrong artifact");
+ }
- $login->processResponseMsg($body);
+ $login->processResponseMsg($response);
$db = &DB::connect($config['dsn']);