Definition at line 7 of file XapiProxyResponse.php.
◆ __construct()
XapiProxy\XapiProxyResponse::__construct |
( |
| ) |
|
Definition at line 13 of file XapiProxyResponse.php.
References $GLOBALS.
15 $this->xapiproxy = $this->dic[
'xapiproxy'];
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
◆ checkResponse()
XapiProxy\XapiProxyResponse::checkResponse |
( |
|
$response, |
|
|
|
$endpoint |
|
) |
| |
Definition at line 18 of file XapiProxyResponse.php.
References Vendor\Package\$e, and $response.
22 $status =
$response[
'value']->getStatusCode();
23 if ($status === 200 || $status === 204 || $status === 404)
29 $this->xapiproxy->log()->error(
"LRS error {$endpoint}: " .
$response[
'value']->getBody());
36 $this->xapiproxy->log()->error(
"Connection error {$endpoint}: " .
$response[
'reason']->getMessage());
40 $this->xapiproxy->log()->error(
"error {$endpoint}:" . $e->getMessage());
◆ emit()
XapiProxy\XapiProxyResponse::emit |
( |
|
$response | ) |
|
Definition at line 189 of file XapiProxyResponse.php.
References $name, and $response.
190 $this->xapiproxy->log()->debug($this->
msg(
'emitting response'));
191 if (headers_sent()) {
192 $this->xapiproxy->log()->error($this->
msg(
"Headers already sent!"));
195 if (ob_get_level() > 0 && ob_get_length() > 0) {
196 $this->xapiproxy->log()->error($this->
msg(
"Outputstream not empty!"));
200 $reasonPhrase =
$response->getReasonPhrase();
201 $statusCode =
$response->getStatusCode();
204 foreach (
$response->getHeaders() as $header => $values) {
205 $name = ucwords($header,
'-');
206 $first =
$name ===
'Set-Cookie' ? false :
true;
207 foreach ($values as $value) {
212 ), $first, $statusCode);
222 ($reasonPhrase ?
' ' . $reasonPhrase :
'')
223 ),
true, $statusCode);
◆ exitBadRequest()
XapiProxy\XapiProxyResponse::exitBadRequest |
( |
| ) |
|
Definition at line 149 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
153 if (isset($origin) && $origin !=
"") {
154 header(
'Access-Control-Allow-Origin: ' . $origin);
156 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
159 $this->xapiproxy->log()->warning($e->getMessage());
161 header(
'Access-Control-Allow-Credentials: true');
162 header(
'X-Experience-API-Version: 1.0.3');
163 header(
"HTTP/1.1 400 XapiProxy Bad Request (Ask For Logs)");
164 echo
"HTTP/1.1 400 XapiProxy Bad Request (Ask For Logs)";
◆ exitProxyError()
XapiProxy\XapiProxyResponse::exitProxyError |
( |
| ) |
|
Definition at line 131 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
134 if (isset($origin) && $origin !=
"") {
135 header(
'Access-Control-Allow-Origin: ' . $origin);
137 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
140 $this->xapiproxy->log()->warning($e->getMessage());
142 header(
'Access-Control-Allow-Credentials: true');
143 header(
'X-Experience-API-Version: 1.0.3');
144 header(
"HTTP/1.1 500 XapiProxy Error (Ask For Logs)");
145 echo
"HTTP/1.1 500 XapiProxy Error (Ask For Logs)";
◆ exitResponseError()
XapiProxy\XapiProxyResponse::exitResponseError |
( |
| ) |
|
Definition at line 113 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
116 if (isset($origin) && $origin !=
"") {
117 header(
'Access-Control-Allow-Origin: ' . $origin);
119 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
122 $this->xapiproxy->log()->warning($e->getMessage());
124 header(
'Access-Control-Allow-Credentials: true');
125 header(
'X-Experience-API-Version: 1.0.3');
126 header(
"HTTP/1.1 412 Wrong Response");
127 echo
"HTTP/1.1 412 Wrong Response";
◆ fakeResponseBlocked()
XapiProxy\XapiProxyResponse::fakeResponseBlocked |
( |
|
$post = NULL | ) |
|
Definition at line 71 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
72 $this->xapiproxy->log()->debug($this->
msg(
"fakeResponseFromBlockedRequest"));
74 $this->xapiproxy->log()->debug($this->
msg(
"post === NULL"));
77 if (isset($origin) && $origin !=
"") {
78 header(
'Access-Control-Allow-Origin: ' . $origin);
80 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
83 $this->xapiproxy->log()->warning($e->getMessage());
85 header(
'Access-Control-Allow-Credentials: true');
86 header(
'X-Experience-API-Version: 1.0.3');
87 header(
'HTTP/1.1 204 No Content');
91 $ids = json_encode($post);
92 $this->xapiproxy->log()->debug($this->
msg(
"post: " . $ids));
95 if (isset($origin) && $origin !=
"") {
96 header(
'Access-Control-Allow-Origin: ' . $origin);
98 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
101 $this->xapiproxy->log()->warning($e->getMessage());
103 header(
'Access-Control-Allow-Credentials: true');
104 header(
'X-Experience-API-Version: 1.0.3');
105 header(
'Content-Length: ' . strlen($ids));
106 header(
'Content-Type: application/json; charset=utf-8');
107 header(
'HTTP/1.1 200 Ok');
◆ handleResponse()
XapiProxy\XapiProxyResponse::handleResponse |
( |
|
$request, |
|
|
|
$response, |
|
|
|
$fakePostBody = NULL |
|
) |
| |
Definition at line 46 of file XapiProxyResponse.php.
References $response.
48 if ($fakePostBody !== NULL) {
50 $this->xapiproxy->log()->debug($this->
msg(
"orig body: " . $origBody));
51 $this->xapiproxy->log()->debug($this->
msg(
"fake body: " . json_encode($fakePostBody)));
58 if (array_key_exists(
'Transfer-Encoding', $headers) && $headers[
'Transfer-Encoding'][0] ==
"chunked") {
59 $this->xapiproxy->log()->debug($this->
msg(
"sniff response transfer-encoding for unallowed Content-length"));
61 unset($headers[
'Transfer-Encoding']);
62 $headers[
'Content-Length'] = array(strlen($body));
63 $response2 = new \GuzzleHttp\Psr7\Response($status,$headers,$body);
64 $this->
emit($response2);
fakeResponseBlocked($post=NULL)
◆ msg()
XapiProxy\XapiProxyResponse::msg |
( |
|
$msg | ) |
|
|
private |
◆ sendData()
XapiProxy\XapiProxyResponse::sendData |
( |
|
$obj | ) |
|
Definition at line 168 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
169 $this->xapiproxy->log()->debug($this->
msg(
"senData: " . $obj));
172 if (isset($origin) && $origin !=
"") {
173 header(
'Access-Control-Allow-Origin: ' . $origin);
175 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
178 $this->xapiproxy->log()->warning($e->getMessage());
180 header(
'Access-Control-Allow-Credentials: true');
181 header(
'X-Experience-API-Version: 1.0.3');
182 header(
'Content-Length: ' . strlen($obj));
183 header(
'Content-Type: application/json; charset=utf-8');
184 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: