/** * This function has got a weird name, because it does not do anything else * only inspect the getOutputFlow function of the output handler and decides * what to do with the $testsring variable it receives. This tries to * emulate the behahviour of the server to the $poc object. * * @param $poc Poc * @param $outputHandler TestOutput * @param $testString string */ public function pocBurner(Poc $poc, $testString = "testString") { if ($poc->getEventDispatcher()->hasPlugin(PocLogs::PLUGIN_NAME)) { $poc->addPlugin(new PocLogs()); } $this->setOutput(''); $poc->start(); if ($poc->getEventDispatcher()->hasPlugin(HttpCapture::PLUGIN_NAME)) { $outputHandler = $poc->getEventDispatcher()->getPlugin(HttpCapture::PLUGIN_NAME)->getOutputHandler(); } if ($outputHandler->getOutputFlow()) { echo $testString; $poc->end(); //var_dump($outputHandler); $this->setHeader($outputHandler->getallheaders()); $this->setOutput($outputHandler->getOutput()); } else { $this->setHeader($outputHandler->getallheaders()); $this->setOutput($outputHandler->getOutput()); $poc->end(); //var_dump($outputHandler); if ($outputHandler->getOutput()) { $this->setHeader($outputHandler->getallheaders()); $this->setOutput($outputHandler->getOutput()); } } }
public function fetchHeaders() { $this->headersToSend = unserialize($this->poc->getCache()->fetch($this->poc->getHasher()->getKey() . self::HEADER_POSTFIX)); if ($this->headersToSend) { foreach ($this->headersToSend as $header) { $this->poc->getEventDispatcher()->getPlugin(HttpCapture::PLUGIN_NAME)->getOutputHandler()->header($header); } } }
public function testEtagReceive() { $hasher = new Hasher(); $hasher->addDistinguishVariable("TestEtag2" . rand()); $poc = new Poc(array(Poc::PARAM_TOOLSET => new HttpCapture(new TestOutput()), PocParams::PARAM_HASHER => $hasher)); $outputHandler = $poc->getEventDispatcher()->getPlugin(HttpCapture::PLUGIN_NAME)->getOutputHandler(); $outputHandler->allheaders['If-None-Match'] = 'c075eba9c04d3faf4ac21fd29cae6fd8'; $poc->addPlugin(new Etag()); $this->pocBurner($poc, self::ETAG_TEXT); $header = $outputHandler->getHeader(); $this->assertTrue(isset($header['HTTP/1.0 304 Not Modified'])); }
public function testContentLenght() { $hasher = new Hasher(); $hasher->addDistinguishVariable("TestContentLength" . rand()); $poc = new Poc(array(Poc::PARAM_TOOLSET => new HttpCapture(new TestOutput()), PocParams::PARAM_HASHER => $hasher)); $outputHandler = $poc->getEventDispatcher()->getPlugin(HttpCapture::PLUGIN_NAME)->getOutputHandler(); $poc->addPlugin(new ContentLength()); $testString = "123"; $this->pocBurner($poc, $testString); $header = $outputHandler->getHeader(); $this->assertEquals(strlen($testString), $header['Content-Length']); }
private function setCompressiontype(Poc $poc) { $httpCapture = $poc->getEventDispatcher()->getPlugin(HttpCapture::PLUGIN_NAME); $outputHandler = $httpCapture->getOutputHandler(); $headers = $outputHandler->getallheaders(); if (isset($headers['Accept-Encoding'])) { if (strstr($headers['Accept-Encoding'], self::COMPRESSION_GZIP)) { $this->compressionType = self::COMPRESSION_GZIP; } else { //die ("CCCCCCCCCCCCC"); } } //$this->compressionType = self::COMPRESSION_DEFLATE; }