Definition at line 7 of file XapiProxyResponse.php.
◆ __construct()
XapiProxy\XapiProxyResponse::__construct |
( |
| ) |
|
Definition at line 13 of file XapiProxyResponse.php.
References $GLOBALS.
16 $this->xapiproxy = $this->dic[
'xapiproxy'];
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
◆ checkResponse()
XapiProxy\XapiProxyResponse::checkResponse |
( |
|
$response, |
|
|
|
$endpoint |
|
) |
| |
Definition at line 19 of file XapiProxyResponse.php.
References Vendor\Package\$e, and $response.
22 $status =
$response[
'value']->getStatusCode();
23 if ($status === 200 || $status === 204 || $status === 404) {
26 $this->xapiproxy->log()->error(
"LRS error {$endpoint}: " .
$response[
'value']->getBody());
31 $this->xapiproxy->log()->error(
"Connection error {$endpoint}: " .
$response[
'reason']->getMessage());
33 $this->xapiproxy->log()->error(
"error {$endpoint}:" . $e->getMessage());
◆ emit()
XapiProxy\XapiProxyResponse::emit |
( |
|
$response | ) |
|
Definition at line 185 of file XapiProxyResponse.php.
References $name, and $response.
187 $this->xapiproxy->log()->debug($this->
msg(
'emitting response'));
188 if (headers_sent()) {
189 $this->xapiproxy->log()->error($this->
msg(
"Headers already sent!"));
192 if (ob_get_level() > 0 && ob_get_length() > 0) {
193 $this->xapiproxy->log()->error($this->
msg(
"Outputstream not empty!"));
197 $reasonPhrase =
$response->getReasonPhrase();
198 $statusCode =
$response->getStatusCode();
201 foreach (
$response->getHeaders() as $header => $values) {
202 $name = ucwords($header,
'-');
203 $first =
$name ===
'Set-Cookie' ? false :
true;
204 foreach ($values as $value) {
209 ), $first, $statusCode);
219 ($reasonPhrase ?
' ' . $reasonPhrase :
'')
220 ),
true, $statusCode);
◆ exitBadRequest()
XapiProxy\XapiProxyResponse::exitBadRequest |
( |
| ) |
|
Definition at line 144 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
148 if (isset($origin) && $origin !=
"") {
149 header(
'Access-Control-Allow-Origin: ' . $origin);
151 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
154 $this->xapiproxy->log()->warning($e->getMessage());
156 header(
'Access-Control-Allow-Credentials: true');
157 header(
'X-Experience-API-Version: 1.0.3');
158 header(
"HTTP/1.1 400 XapiProxy Bad Request (Ask For Logs)");
159 echo
"HTTP/1.1 400 XapiProxy Bad Request (Ask For Logs)";
◆ exitProxyError()
XapiProxy\XapiProxyResponse::exitProxyError |
( |
| ) |
|
Definition at line 125 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
129 if (isset($origin) && $origin !=
"") {
130 header(
'Access-Control-Allow-Origin: ' . $origin);
132 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
135 $this->xapiproxy->log()->warning($e->getMessage());
137 header(
'Access-Control-Allow-Credentials: true');
138 header(
'X-Experience-API-Version: 1.0.3');
139 header(
"HTTP/1.1 500 XapiProxy Error (Ask For Logs)");
140 echo
"HTTP/1.1 500 XapiProxy Error (Ask For Logs)";
◆ exitResponseError()
XapiProxy\XapiProxyResponse::exitResponseError |
( |
| ) |
|
Definition at line 106 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
110 if (isset($origin) && $origin !=
"") {
111 header(
'Access-Control-Allow-Origin: ' . $origin);
113 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
116 $this->xapiproxy->log()->warning($e->getMessage());
118 header(
'Access-Control-Allow-Credentials: true');
119 header(
'X-Experience-API-Version: 1.0.3');
120 header(
"HTTP/1.1 412 Wrong Response");
121 echo
"HTTP/1.1 412 Wrong Response";
◆ fakeResponseBlocked()
XapiProxy\XapiProxyResponse::fakeResponseBlocked |
( |
|
$post = null | ) |
|
Definition at line 64 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
66 $this->xapiproxy->log()->debug($this->
msg(
"fakeResponseFromBlockedRequest"));
68 $this->xapiproxy->log()->debug($this->
msg(
"post === NULL"));
71 if (isset($origin) && $origin !=
"") {
72 header(
'Access-Control-Allow-Origin: ' . $origin);
74 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
77 $this->xapiproxy->log()->warning($e->getMessage());
79 header(
'Access-Control-Allow-Credentials: true');
80 header(
'X-Experience-API-Version: 1.0.3');
81 header(
'HTTP/1.1 204 No Content');
84 $ids = json_encode($post);
85 $this->xapiproxy->log()->debug($this->
msg(
"post: " . $ids));
88 if (isset($origin) && $origin !=
"") {
89 header(
'Access-Control-Allow-Origin: ' . $origin);
91 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
94 $this->xapiproxy->log()->warning($e->getMessage());
96 header(
'Access-Control-Allow-Credentials: true');
97 header(
'X-Experience-API-Version: 1.0.3');
98 header(
'Content-Length: ' . strlen($ids));
99 header(
'Content-Type: application/json; charset=utf-8');
100 header(
'HTTP/1.1 200 Ok');
◆ handleResponse()
XapiProxy\XapiProxyResponse::handleResponse |
( |
|
$request, |
|
|
|
$response, |
|
|
|
$fakePostBody = null |
|
) |
| |
Definition at line 39 of file XapiProxyResponse.php.
References $response.
42 if ($fakePostBody !== null) {
44 $this->xapiproxy->log()->debug($this->
msg(
"orig body: " . $origBody));
45 $this->xapiproxy->log()->debug($this->
msg(
"fake body: " . json_encode($fakePostBody)));
52 if (array_key_exists(
'Transfer-Encoding', $headers) && $headers[
'Transfer-Encoding'][0] ==
"chunked") {
53 $this->xapiproxy->log()->debug($this->
msg(
"sniff response transfer-encoding for unallowed Content-length"));
55 unset($headers[
'Transfer-Encoding']);
56 $headers[
'Content-Length'] = array(strlen($body));
57 $response2 = new \GuzzleHttp\Psr7\Response($status, $headers, $body);
58 $this->
emit($response2);
fakeResponseBlocked($post=null)
◆ msg()
XapiProxy\XapiProxyResponse::msg |
( |
|
$msg | ) |
|
|
private |
◆ sendData()
XapiProxy\XapiProxyResponse::sendData |
( |
|
$obj | ) |
|
Definition at line 163 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
165 $this->xapiproxy->log()->debug($this->
msg(
"senData: " . $obj));
168 if (isset($origin) && $origin !=
"") {
169 header(
'Access-Control-Allow-Origin: ' . $origin);
171 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
174 $this->xapiproxy->log()->warning($e->getMessage());
176 header(
'Access-Control-Allow-Credentials: true');
177 header(
'X-Experience-API-Version: 1.0.3');
178 header(
'Content-Length: ' . strlen($obj));
179 header(
'Content-Type: application/json; charset=utf-8');
180 header(
'HTTP/1.1 200 Ok');
◆ $dic
XapiProxy\XapiProxyResponse::$dic |
|
private |
◆ $xapiproxy
XapiProxy\XapiProxyResponse::$xapiproxy |
|
private |
The documentation for this class was generated from the following file: