public function testDefaultHeader() { Unirest\Request::defaultHeader('Hello', 'custom'); $response = Unirest\Request::get('http://httpbin.org/get'); $this->assertEquals(200, $response->code); $headers = $response->body->headers; $properties = get_object_vars($headers); $this->assertTrue(array_key_exists('Hello', $properties)); $this->assertEquals('custom', $headers->Hello); $response = Unirest\Request::get('http://httpbin.org/get'); $this->assertEquals(200, $response->code); $headers = $response->body->headers; $properties = get_object_vars($headers); $this->assertTrue(array_key_exists('Hello', $properties)); $this->assertEquals('custom', $headers->Hello); Unirest\Request::clearDefaultHeaders(); $response = Unirest\Request::get('http://httpbin.org/get'); $this->assertEquals(200, $response->code); $headers = $response->body->headers; $properties = get_object_vars($headers); $this->assertFalse(array_key_exists('Hello', $properties)); }
public function testDefaultHeader() { Unirest\Request::defaultHeader('Hello', 'custom'); $response = Unirest\Request::get('http://mockbin.com/request'); $this->assertEquals(200, $response->code); $this->assertTrue(property_exists($response->body->headers, 'hello')); $this->assertEquals('custom', $response->body->headers->hello); Unirest\Request::clearDefaultHeaders(); $response = Unirest\Request::get('http://mockbin.com/request'); $this->assertEquals(200, $response->code); $this->assertFalse(property_exists($response->body->headers, 'hello')); }
public function delete($url) { Unirest\Request::auth($this->login, $this->pass); Unirest\Request::defaultHeader('User-Agent', $this->service . " (" . $this->mail . ")"); $response = Unirest\Request::delete($this->root . $url . '.json'); if (floor($response->code / 100) >= 4) { throw new Error($response->body->errors->error[0]); } return $response->body; }