amend response Header

This commit is contained in:
a-sansara 2017-03-21 02:54:36 +01:00
parent 20399c4ae7
commit fb15b5652a
2 changed files with 10 additions and 9 deletions

View File

@ -18,6 +18,7 @@
}, },
"require" : { "require" : {
"php" : ">=5.4", "php" : ">=5.4",
"meta-tech/pws-auth" : "^2.1" "meta-tech/pws-auth" : "@dev",
"symfony/yaml": "^3.2"
} }
} }

View File

@ -275,17 +275,16 @@ class Client
$authresponse = false; $authresponse = false;
try { try {
$lines = explode(PHP_EOL, $respheader); $lines = explode(PHP_EOL, $respheader);
var_dump(compact('lines'));
$arrheader = []; $arrheader = [];
foreach($lines as $line) { foreach($lines as $line) {
$match = preg_split('/:/', $line, 1); if (!empty($line)) {
if (count($match)==2) { $match = preg_split('/: /', $line, 2);
$arrheader[$match[0]] = trim($arrheader[$match[1]]); if (count($match)==2) {
$arrheader[$match[0]] = trim($match[1]);
}
} }
} }
$h = $this->authenticator->readHeader($arrheader); $authresponse = isset($arrheader['Pws-Response']) && $arrheader['Pws-Response'] == $this->responseToken;
var_dump(compact('h'));
$authresponse = isset($h['Pws-Response']) && $h['Pws-Response'] == $this->responseToken;
} }
catch(\Exception $e) { catch(\Exception $e) {
@ -308,6 +307,7 @@ class Client
} }
} }
if ($this->config['debug']) { if ($this->config['debug']) {
$responseToken = $this->responseToken;
$respcontent = null; $respcontent = null;
if (is_object($response)) { if (is_object($response)) {
$respcontent = clone $response; $respcontent = clone $response;
@ -339,7 +339,7 @@ class Client
'HEADER' => $this->authenticator->readHeader($header), 'HEADER' => $this->authenticator->readHeader($header),
'PARAMS' => $data, 'PARAMS' => $data,
'METHOD' => $method, 'METHOD' => $method,
'RESPONSE' => compact('date', 'uri', 'status') + ['curl' => $rs, 'response' => $respcontent] 'RESPONSE' => compact('date', 'uri', 'status', 'responseToken', 'authresponse') + ['curl' => $rs, 'response' => $respcontent]
], true) . Formatter::LF; ], true) . Formatter::LF;
array_unshift($tags, $traces); array_unshift($tags, $traces);
$this->formatter->writeTags($tags); $this->formatter->writeTags($tags);