/**
  * Creates a new request object
  *
  * @param   string method
  * @param   peer.URL url
  * @return  scriptlet.xml.XMLScriptletRequest
  */
 protected function newRequest($method, URL $url)
 {
     $q = $url->getQuery('');
     $req = new XMLScriptletRequest();
     $req->method = $method;
     $req->env['SERVER_PROTOCOL'] = 'HTTP/1.1';
     $req->env['REQUEST_URI'] = $url->getPath('/') . ($q ? '?' . $q : '');
     $req->env['QUERY_STRING'] = $q;
     $req->env['HTTP_HOST'] = $url->getHost();
     $req->env['LANGUAGE'] = 'en_US';
     if ('https' === $url->getScheme()) {
         $req->env['HTTPS'] = 'on';
     }
     $req->setHeaders(array());
     $req->setParams($url->getParams());
     return $req;
 }
 /**
  * Initialize this request object - overridden from base class.
  *
  * @see     xp://scriptlet.xml.XMLScriptletRequest#initialize
  */
 public function initialize()
 {
     parent::initialize();
     if ($this->stateName) {
         $name = implode('', array_map('ucfirst', array_reverse(explode('/', $this->stateName))));
         try {
             $this->state = XPClass::forName($this->package . '.' . ('state.' . $name . 'State'))->newInstance();
         } catch (ClassNotFoundException $e) {
             throw new ScriptletException('Cannot find ' . $this->stateName, HttpConstants::STATUS_NOT_FOUND, $e);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Helper method to simulate form submission
  *
  */
 protected function loadFromRequest($params = array())
 {
     $r = new XMLScriptletRequest();
     foreach ($params as $key => $value) {
         $r->setParam($key, $value);
     }
     $this->wrapper->load($r, $this->handler);
 }