Definition at line 27 of file XapiProxyResponse.php.
◆ __construct()
XapiProxy\XapiProxyResponse::__construct |
( |
XapiProxy |
$xapiproxy | ) |
|
◆ checkResponse()
XapiProxy\XapiProxyResponse::checkResponse |
( |
array |
$response, |
|
|
string |
$endpoint |
|
) |
| |
Definition at line 39 of file XapiProxyResponse.php.
References Vendor\Package\$e.
42 $status =
$response[
'value']->getStatusCode();
43 if ($status === 200 || $status === 204 || $status === 404) {
46 $this->xapiproxy->log()->error(
"LRS error {$endpoint}: " .
$response[
'value']->getBody());
51 $this->xapiproxy->log()->error(
"Connection error {$endpoint}: " .
$response[
'reason']->getMessage());
53 $this->xapiproxy->log()->error(
"error {$endpoint}:" . $e->getMessage());
◆ emit()
XapiProxy\XapiProxyResponse::emit |
( |
\GuzzleHttp\Psr7\Response |
$response | ) |
|
Definition at line 215 of file XapiProxyResponse.php.
References $name.
217 $this->xapiproxy->log()->debug($this->
msg(
'emitting response'));
218 if (headers_sent()) {
219 $this->xapiproxy->log()->error($this->
msg(
"Headers already sent!"));
222 if (ob_get_level() > 0 && ob_get_length() > 0) {
223 $this->xapiproxy->log()->error($this->
msg(
"Outputstream not empty!"));
227 $reasonPhrase =
$response->getReasonPhrase();
228 $statusCode =
$response->getStatusCode();
231 foreach (
$response->getHeaders() as $header => $values) {
232 $name = ucwords($header,
'-');
233 $first =
$name ===
'Set-Cookie' ? false :
true;
234 foreach ($values as $value) {
239 ), $first, $statusCode);
249 ($reasonPhrase ?
' ' . $reasonPhrase :
'')
250 ),
true, $statusCode);
◆ exitBadRequest()
XapiProxy\XapiProxyResponse::exitBadRequest |
( |
| ) |
|
Definition at line 174 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
178 if (isset($origin) && $origin !=
"") {
179 header(
'Access-Control-Allow-Origin: ' . $origin);
181 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
184 $this->xapiproxy->log()->warning($e->getMessage());
186 header(
'Access-Control-Allow-Credentials: true');
187 header(
'X-Experience-API-Version: 1.0.3');
188 header(
"HTTP/1.1 400 XapiProxy Bad Request (Ask For Logs)");
189 echo
"HTTP/1.1 400 XapiProxy Bad Request (Ask For Logs)";
◆ exitProxyError()
XapiProxy\XapiProxyResponse::exitProxyError |
( |
| ) |
|
Definition at line 155 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
159 if (isset($origin) && $origin !=
"") {
160 header(
'Access-Control-Allow-Origin: ' . $origin);
162 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
165 $this->xapiproxy->log()->warning($e->getMessage());
167 header(
'Access-Control-Allow-Credentials: true');
168 header(
'X-Experience-API-Version: 1.0.3');
169 header(
"HTTP/1.1 500 XapiProxy Error (Ask For Logs)");
170 echo
"HTTP/1.1 500 XapiProxy Error (Ask For Logs)";
◆ exitResponseError()
XapiProxy\XapiProxyResponse::exitResponseError |
( |
| ) |
|
Definition at line 136 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
140 if (isset($origin) && $origin !=
"") {
141 header(
'Access-Control-Allow-Origin: ' . $origin);
143 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
146 $this->xapiproxy->log()->warning($e->getMessage());
148 header(
'Access-Control-Allow-Credentials: true');
149 header(
'X-Experience-API-Version: 1.0.3');
150 header(
"HTTP/1.1 412 Wrong Response");
151 echo
"HTTP/1.1 412 Wrong Response";
◆ fakeResponseBlocked()
XapiProxy\XapiProxyResponse::fakeResponseBlocked |
( |
|
$post = null | ) |
|
- Parameters
-
string | array | null | $post | |
- Returns
- void
Definition at line 94 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, $post, and exit.
96 $this->xapiproxy->log()->debug($this->
msg(
"fakeResponseFromBlockedRequest"));
98 $this->xapiproxy->log()->debug($this->
msg(
"post === NULL"));
101 if (isset($origin) && $origin !=
"") {
102 header(
'Access-Control-Allow-Origin: ' . $origin);
104 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
107 $this->xapiproxy->log()->warning($e->getMessage());
109 header(
'Access-Control-Allow-Credentials: true');
110 header(
'X-Experience-API-Version: 1.0.3');
111 header(
'HTTP/1.1 204 No Content');
114 $ids = json_encode(
$post);
115 $this->xapiproxy->log()->debug($this->
msg(
"post: " . $ids));
118 if (isset($origin) && $origin !=
"") {
119 header(
'Access-Control-Allow-Origin: ' . $origin);
121 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
124 $this->xapiproxy->log()->warning($e->getMessage());
126 header(
'Access-Control-Allow-Credentials: true');
127 header(
'X-Experience-API-Version: 1.0.3');
128 header(
'Content-Length: ' . strlen($ids));
129 header(
'Content-Type: application/json; charset=utf-8');
130 header(
'HTTP/1.1 200 Ok');
◆ handleResponse()
XapiProxy\XapiProxyResponse::handleResponse |
( |
Request |
$request, |
|
|
Response |
$response, |
|
|
|
$fakePostBody = null |
|
) |
| |
- Parameters
-
Request | $request | |
Response | $response | |
string | array | null | $fakePostBody | |
- Returns
- void
Definition at line 65 of file XapiProxyResponse.php.
68 if ($fakePostBody !== null) {
70 $this->xapiproxy->log()->debug($this->
msg(
"orig body: " . $origBody));
71 $this->xapiproxy->log()->debug($this->
msg(
"fake body: " . json_encode($fakePostBody)));
78 if (array_key_exists(
'Transfer-Encoding', $headers) && $headers[
'Transfer-Encoding'][0] ==
"chunked") {
79 $this->xapiproxy->log()->debug($this->
msg(
"sniff response transfer-encoding for unallowed Content-length"));
81 unset($headers[
'Transfer-Encoding']);
82 $headers[
'Content-Length'] = array(strlen($body));
83 $response2 = new \GuzzleHttp\Psr7\Response($status, $headers, $body);
84 $this->
emit($response2);
emit(\GuzzleHttp\Psr7\Response $response)
fakeResponseBlocked($post=null)
◆ msg()
XapiProxy\XapiProxyResponse::msg |
( |
string |
$msg | ) |
|
|
private |
◆ sendData()
XapiProxy\XapiProxyResponse::sendData |
( |
string |
$obj | ) |
|
Definition at line 193 of file XapiProxyResponse.php.
References $_SERVER, Vendor\Package\$e, and exit.
195 $this->xapiproxy->log()->debug($this->
msg(
"sendData: " . $obj));
198 if (isset($origin) && $origin !=
"") {
199 header(
'Access-Control-Allow-Origin: ' . $origin);
201 $this->xapiproxy->log()->warning(
"could not get \$_SERVER[\"HTTP_ORIGIN\"] or \$_SERVER[\"HTTP_REFERRER\"]");
204 $this->xapiproxy->log()->warning($e->getMessage());
206 header(
'Access-Control-Allow-Credentials: true');
207 header(
'X-Experience-API-Version: 1.0.3');
208 header(
'Content-Length: ' . strlen($obj));
209 header(
'Content-Type: application/json; charset=utf-8');
210 header(
'HTTP/1.1 200 Ok');
◆ $xapiproxy
XapiProxy XapiProxy\XapiProxyResponse::$xapiproxy |
|
private |
The documentation for this class was generated from the following file: