예제 #1
0
 /**
  * Http request
  *
  * @param string $method
  * @param string $url
  * @param array  $submit
  * @param string $formName
  *
  * @return HTTP_Request2_Response
  */
 public function request($method, $url, array $submit = array(), $formName = 'form')
 {
     $this->request = new HTTP_Request2();
     $url = new Net_URL2($url);
     $this->request->setMethod($method);
     if ($submit) {
         $submit = array_merge(array('_token' => '0dc59902014b6', '_qf__' . $formName => ''), $submit);
     }
     if ($submit && $method === 'POST') {
         $this->request->addPostParameter($submit);
     }
     if ($submit && $method === 'GET') {
         $url->setQueryVariables($submit);
     }
     $this->request->setUrl($url);
     $this->response = $this->request->send();
     return $this;
 }
예제 #2
0
파일: Assertion.php 프로젝트: shupp/openid
 /**
  * Validates the openid.return_to parameter in the response.
  * 
  * @return void
  * @throws OpenID_Assertion_Exception on failure
  */
 protected function validateReturnTo()
 {
     $returnTo = $this->message->get('openid.return_to');
     OpenID::setLastEvent(__METHOD__, 'openid.return_to: ' . var_export($returnTo, true));
     // Validate openid.return_to
     if (!filter_var($returnTo, FILTER_VALIDATE_URL)) {
         throw new OpenID_Assertion_Exception('openid.return_to parameter is invalid or missing');
     }
     $obj1 = new Net_URL2($returnTo);
     $obj2 = $this->requestedURL;
     $queryString1 = $obj1->getQueryVariables();
     $queryString2 = $obj2->getQueryVariables();
     $obj1->setQueryVariables(array());
     $obj2->setQueryVariables(array());
     if ($obj1->getURL() != $obj2->getURL()) {
         throw new OpenID_Assertion_Exception('openid.return_to does not match the requested URL');
     }
     if (!count($queryString1) && !count($queryString2)) {
         return;
     }
     foreach ($queryString1 as $param => $value) {
         if (!isset($queryString2[$param]) || $queryString2[$param] != $value) {
             throw new OpenID_Assertion_Exception('openid.return_to parameters do not match requested url');
         }
     }
 }
예제 #3
0
 public function testDontUseBrackets()
 {
     $url = new Net_URL2('http://example.org/', array(Net_URL2::OPTION_USE_BRACKETS => false));
     $url->setQueryVariables(array('foo' => array('bar', 'foobar')));
     $this->assertEquals('http://example.org/?foo=bar&foo=foobar', strval($url));
 }