예제 #1
0
 public function __construct(array $hostInfo)
 {
     $this->_hostInfo = $hostInfo;
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_SERVER[ODataConstants::HTTPREQUEST_PROTOCOL] = $this->_hostInfo['AbsoluteRequestUri']->getScheme();
     $_SERVER[HttpProcessUtility::headerToServerKey(ODataConstants::HTTPREQUEST_HEADER_HOST)] = $this->_hostInfo['AbsoluteRequestUri']->getHost() . ':' . $this->_hostInfo['AbsoluteRequestUri']->getPort();
     $_SERVER[ODataConstants::HTTPREQUEST_URI] = $this->_hostInfo['AbsoluteRequestUri']->getPath();
     if (array_key_exists('DataServiceVersion', $this->_hostInfo)) {
         $_SERVER[HttpProcessUtility::headerToServerKey(ODataConstants::HTTPREQUEST_HEADER_DATA_SERVICE_VERSION)] = $this->_hostInfo['DataServiceVersion']->toString();
     }
     if (array_key_exists('MaxDataServiceVersion', $this->_hostInfo)) {
         $_SERVER[HttpProcessUtility::headerToServerKey(ODataConstants::HTTPREQUEST_HEADER_MAX_DATA_SERVICE_VERSION)] = $this->_hostInfo['MaxDataServiceVersion']->toString();
     }
     if (array_key_exists('RequestIfMatch', $this->_hostInfo)) {
         $_SERVER[HttpProcessUtility::headerToServerKey(ODataConstants::HTTPREQUEST_HEADER_IF_MATCH)] = $this->_hostInfo['RequestIfMatch'];
     }
     if (array_key_exists('RequestIfNoneMatch', $this->_hostInfo)) {
         $_SERVER[HttpProcessUtility::headerToServerKey(ODataConstants::HTTPREQUEST_HEADER_IF_NONE)] = $this->_hostInfo['RequestIfNoneMatch'];
     }
     if (array_key_exists('QueryString', $this->_hostInfo)) {
         $_SERVER[ODataConstants::HTTPREQUEST_QUERY_STRING] = $this->_hostInfo['QueryString'];
     }
     //print_r($_SERVER);
     parent::__construct();
     if (array_key_exists('AbsoluteServiceUri', $this->_hostInfo)) {
         $this->setServiceUri($this->_hostInfo['AbsoluteServiceUri']->getUrlAsString());
     }
 }
예제 #2
0
 /**
  * get the specific request headers
  * 
  * @param string $key The header name
  * 
  * @return string|null value of the header, NULL if header is absent.
  */
 public function getRequestHeader($key)
 {
     //PHP normalizes header keys
     $trimmedKey = HttpProcessUtility::headerToServerKey(trim($key));
     // todo: lion
     // if (array_key_exists($trimmedKey, $this->_headers)) {
     if ($this->_headers != null && array_key_exists($trimmedKey, $this->_headers)) {
         return $this->_headers[$trimmedKey];
     }
     return null;
 }
 /**
  * Tests inlinecount
  */
 function testInlineCountNone()
 {
     $_SERVER[ODataConstants::HTTPREQUEST_METHOD] = ODataConstants::HTTP_METHOD_GET;
     $_SERVER[ODataConstants::HTTPREQUEST_PROTOCOL] = ODataConstants::HTTPREQUEST_PROTOCOL_HTTP;
     $_SERVER[HttpProcessUtility::headerToServerKey(ODataConstants::HTTPREQUEST_HEADER_HOST)] = "localhost:8086";
     $_SERVER[ODataConstants::HTTPREQUEST_URI] = "/NorthWind.svc/Customers";
     $_SERVER[ODataConstants::HTTPREQUEST_QUERY_STRING] = '$inlinecount=none';
     $dispatcher = new Dispatcher();
     $dispatcher->dispatch();
     $my_str = ob_get_contents();
     ob_end_clean();
     $this->assertStringStartsWith('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n" . '<feed', $my_str);
     $this->assertStringEndsWith('</feed>' . "\n", $my_str);
 }
예제 #4
0
 function testSetResponseVersion()
 {
     $_SERVER[ODataConstants::HTTPREQUEST_METHOD] = ODataConstants::HTTP_METHOD_GET;
     $_SERVER[ODataConstants::HTTPREQUEST_PROTOCOL] = ODataConstants::HTTPREQUEST_PROTOCOL_HTTP;
     $_SERVER[HttpProcessUtility::headerToServerKey(ODataConstants::HTTPREQUEST_HEADER_HOST)] = "localhost:8086";
     $_SERVER[ODataConstants::HTTPREQUEST_URI] = "/NorthWind.svc/Customers";
     try {
         $exceptionThrown = false;
         $dispatcher = new dispatcher();
         //Service dispatched
         //$dispatcher->dispatch();
         $contents = ob_get_contents();
         ob_end_clean();
         $dispatcher->getHost()->setResponseVersion("2.0");
         $headers =& $dispatcher->getHost()->getWebOperationContext()->OutgoingResponse()->getHeaders();
         $this->assertEquals('2.0', $headers[ODataConstants::ODATAVERSIONHEADER]);
     } catch (\Exception $exception) {
         if (ob_get_length()) {
             ob_end_clean();
         }
         $exceptionThrown = true;
         $this->fail("Some unexpected exception has been thrown:", $exception->getMessage());
     }
 }