/** * Perform any request * * @param string $method request method, e.g. HttpConstants::GET * @param var $parameters * @param [:string] $headers default array() * @return peer.http.HttpResponse response object * @throws io.IOException */ public function request($method, $parameters, $headers = []) { $r = new HttpRequest($this->url); $r->setMethod($method); $r->setParameters($parameters); $r->addHeaders($headers); return $this->send($r); }
public function get_url_with_assoc_array_containing_assoc_array() { $r = new HttpRequest(new URL('http://example.com/')); $r->setMethod(HttpConstants::GET); $r->setParameters(['test' => ['10 EUR' => 'test 123']]); $this->assertEquals("GET /?test[10+EUR]=test+123 HTTP/1.1\r\nConnection: close\r\nHost: example.com\r\n\r\n", $r->getRequestString()); }
public function delete_with_1byte_body() { $r = new HttpRequest(new URL('http://example.com/')); $r->setMethod(HttpConstants::DELETE); $r->setParameters(new RequestData('1')); $this->assertEquals("DELETE / HTTP/1.1\r\nConnection: close\r\nHost: example.com\r\nContent-Length: 1\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", $r->getHeaderString()); }