public function testCastsToString() { $m = new puzzle_message_Request('GET', 'http://foo.com'); $m->setHeader('foo', 'bar'); $m->setBody(puzzle_stream_Stream::factory('baz')); $this->assertEquals("GET / HTTP/1.1\r\nHost: foo.com\r\nfoo: bar\r\n\r\nbaz", (string) $m); }
public function testSetsTransferEncodingChunkedIfNeeded() { $r = new puzzle_message_Request('PUT', '/'); $s = $this->getMockBuilder('puzzle_stream_StreamInterface')->setMethods(array('getSize'))->getMockForAbstractClass(); $s->expects($this->exactly(2))->method('getSize')->will($this->returnValue(null)); $r->setBody($s); $t = $this->getTrans($r); $s = new puzzle_subscriber_Prepare(); $s->onBefore(new puzzle_event_BeforeEvent($t)); $this->assertEquals('chunked', $r->getHeader('Transfer-Encoding')); }