コード例 #1
0
ファイル: RequestTest.php プロジェクト: Gninety/Microweber
 function testDefaultInputStream()
 {
     $h = fopen('php://memory', 'r+');
     fwrite($h, 'testing');
     rewind($h);
     $previousValue = Sabre_HTTP_Request::$defaultInputStream;
     Sabre_HTTP_Request::$defaultInputStream = $h;
     $this->assertEquals('testing', $this->request->getBody(true), 'We didn\'t get our testbody back');
     Sabre_HTTP_Request::$defaultInputStream = $previousValue;
 }
コード例 #2
0
 /**
  * Sets the contents of the HTTP request body
  *
  * This method can either accept a string, or a readable stream resource.
  *
  * If the setAsDefaultInputStream is set to true, it means for this run of the
  * script the supplied body will be used instead of php://input.
  *
  * @param mixed $body
  * @param bool $setAsDefaultInputStream
  * @return void
  */
 public function setBody($body, $setAsDefaultInputStream = false)
 {
     if (is_resource($body)) {
         $this->body = $body;
     } else {
         $stream = fopen('php://temp', 'r+');
         fputs($stream, $body);
         rewind($stream);
         // String is assumed
         $this->body = $stream;
     }
     if ($setAsDefaultInputStream) {
         self::$defaultInputStream = $this->body;
     }
 }