Пример #1
0
 /**
  * @dataProvider exampleSessionToken
  */
 public function testRequestContextRealIp($sessionToken)
 {
     Castle::getTokenStore()->setSession($sessionToken);
     $_SERVER['HTTP_X_REAL_IP'] = '2.2.2.2';
     Castle::track(array('name' => '$login.failed'));
     $this->assertRequest('post', '/events', array('X-Castle-Ip' => '2.2.2.2'));
 }
Пример #2
0
 public function send($method, $url, $params = null)
 {
     $this->preFlightCheck();
     $client = self::clientUserAgent();
     $body = empty($params) ? null : json_encode($params);
     $cookies = Castle::getCookieStore();
     $requestHeaders = json_encode(self::getHeaders());
     $headers = array('X-Castle-Cookie-Id: ' . $cookies->read('__cid'), 'X-Castle-User-Agent: ' . self::getUserAgent(), 'X-Castle-Headers: ' . $requestHeaders, 'X-Castle-Ip: ' . self::getIp(), 'X-Castle-Client-User-Agent: ' . $client, 'Content-Type: application/json', 'Content-Length: ' . strlen($body));
     // Check if there is a current session and pass it along
     $session = Castle::getTokenStore()->getSession();
     if (isset($session)) {
         $headers[] = 'X-Castle-Session-Token: ' . $session;
     }
     $request = new Castle_RequestTransport();
     $request->send($method, self::apiUrl($url), $body, $headers);
     return $this->handleResponse($request);
 }