public function testBuildSimpleCookie() { $cookies = new Cookie(); $this->assertEquals('', CookieHandler::build($cookies, 'my-key')); $cookies = new Cookie(array('foo' => 'bar')); $headers = CookieHandler::build($cookies, 'my-key'); $this->assertEquals('Set-Cookie: foo=czozOiJiYXIiOw.6o_2mL7ZL4HgcezUZT4Nn9VcIuM; ' . "\r\n", $headers); $cookies['bar'] = 'foo'; $headers = CookieHandler::build($cookies, 'my-key'); $this->assertEquals("Set-Cookie: foo=czozOiJiYXIiOw.6o_2mL7ZL4HgcezUZT4Nn9VcIuM; \r\nSet-Cookie: bar=czozOiJmb28iOw.pa7EFOZK0OkBpqpaS_P2Qo1Zccw; \r\n", $headers); }
/** * Get the headers. * */ function getHeaders() { $hdrs = 'HTTP/1.1 ' . $this->status_code . ' ' . $this->status_code_list[$this->status_code] . "\r\n"; foreach ($this->headers as $header => $ch) { $hdrs .= $header . ': ' . $ch . "\r\n"; } $hdrs .= CookieHandler::build($this->COOKIE, Conf::f('secret_key', '')); return $hdrs; }