public function testRedirectsWithGetOn303() { $h = new History(); $mock = new Mock(["HTTP/1.1 303 Moved Permanently\r\nLocation: /redirect\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"]); $client = new Client(); $client->getEmitter()->attach($mock); $client->getEmitter()->attach($h); $client->post('http://test.com/foo', ['body' => 'testing']); $requests = $h->getRequests(true); $this->assertEquals('POST', $requests[0]->getMethod()); $this->assertEquals('GET', $requests[1]->getMethod()); }
public function testCanForceMultipartUploadWithContentType() { $client = new Client(); $client->getEmitter()->attach(new Mock([new Response(200)])); $history = new History(); $client->getEmitter()->attach($history); $client->post('http://foo.com', ['headers' => ['Content-Type' => 'multipart/form-data'], 'body' => ['foo' => 'bar']]); $this->assertContains('multipart/form-data; boundary=', $history->getLastRequest()->getHeader('Content-Type')); $this->assertContains("Content-Disposition: form-data; name=\"foo\"\r\n\r\nbar", (string) $history->getLastRequest()->getBody()); }