Exemplo n.º 1
0
 /**
  * @group ZF2-78
  * @dataProvider parameterArrayProvider
  */
 public function testContentTypeAdditionlInfo($params)
 {
     $content_type = 'application/x-www-form-urlencoded; charset=UTF-8';
     $this->client->setUri($this->baseuri . 'testPostData.php');
     $this->client->setHeaders(array('Content-Type' => $content_type));
     $this->client->setMethod(\Zend\Http\Request::METHOD_POST);
     $this->client->setParameterPost($params);
     $this->client->send();
     $request = Request::fromString($this->client->getLastRawRequest());
     $this->assertEquals($content_type, $request->headers()->get('Content-Type')->getFieldValue());
 }
Exemplo n.º 2
0
 /**
  * Test that we can deal with double Content-Length headers
  *
  * @link http://framework.zend.com/issues/browse/ZF-9404
  */
 public function testZF9404DoubleContentLengthHeader()
 {
     $this->client->setUri($this->baseuri . 'ZF9404-doubleContentLength.php');
     $expect = filesize(dirname(realpath(__FILE__)) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ZF9404-doubleContentLength.php');
     $response = $this->client->send();
     if (!$response->isSuccess()) {
         throw new AdapterException\RuntimeException("Error requesting test URL");
     }
     $clen = $response->headers()->get('Content-Length');
     if (!is_array($clen)) {
         $this->markTestSkipped("Didn't get multiple Content-length headers");
     }
     $this->assertEquals($expect, strlen($response->getBody()));
 }
Exemplo n.º 3
0
 /**
  * Test that we properly calculate the content-length of multibyte-encoded
  * request body
  *
  * This may file in case that mbstring overloads the substr and strlen
  * functions, and the mbstring internal encoding is a multibyte encoding.
  *
  * @link http://framework.zend.com/issues/browse/ZF-2098
  */
 public function testMultibyteRawPostDataZF2098()
 {
     $this->_client->setAdapter('Zend\\Http\\Client\\Adapter\\Test');
     $this->_client->setUri('http://example.com');
     $bodyFile = __DIR__ . '/_files/ZF2098-multibytepostdata.txt';
     $this->_client->setRawBody(file_get_contents($bodyFile));
     $this->_client->setEncType('text/plain');
     $this->_client->setMethod('POST');
     $this->_client->send();
     $request = $this->_client->getLastRequest();
     if (!preg_match('/^content-length:\\s+(\\d+)/mi', $request, $match)) {
         $this->fail("Unable to find content-length header in request");
     }
     $this->assertEquals(filesize($bodyFile), (int) $match[1]);
 }
Exemplo n.º 4
0
 public function testHttpGet()
 {
     $this->client->setMethod(Request::METHOD_GET);
     $response= $this->client->send();
     $this->assertTrue($response->isSuccess());
 }