/**
  * Get the most recent response's content
  *
  * @return string
  */
 public function lastContent()
 {
     if (is_string($this->lastResponse)) {
         return $this->lastResponse;
     } else {
         return $this->lastResponse->getBody();
     }
 }
 /**
  * @return string
  */
 public function getContent()
 {
     return $this->response->getBody();
 }
 /**
  * Assert that a response matches the given parameters
  *
  * @param int $code HTTP code
  * @param string $body Body expected for 200 responses
  * @param HTTPResponse $response
  */
 protected function assertResponseEquals($code, $body, HTTPResponse $response)
 {
     $this->assertEquals($code, $response->getStatusCode());
     if ($code === 200) {
         $this->assertFalse($response->isError());
         $this->assertEquals($body, $response->getBody());
         $this->assertEquals('text/plain', $response->getHeader('Content-Type'));
     } else {
         $this->assertTrue($response->isError());
     }
 }
 /**
  * Performs the following replacements:
  * - Check user defined content type and use it, if it's empty use the text/html.
  * - If find a XML header replaces it and existing doctypes with HTML4.01 Strict.
  * - Replaces self-closing tags like <img /> with unclosed solitary tags like <img>.
  * - Replaces all occurrences of "application/xhtml+xml" with "text/html" in the template.
  * - Removes "xmlns" attributes and any <?xml> Pragmas.
  *
  * @param HTTPResponse $response
  */
 public function html(HTTPResponse $response)
 {
     $encoding = $this->config()->get('encoding');
     $contentType = $this->config()->get('content_type');
     if (empty($contentType)) {
         $response->addHeader("Content-Type", "text/html; charset=" . $encoding);
     } else {
         $response->addHeader("Content-Type", $contentType . "; charset=" . $encoding);
     }
     $response->addHeader("Vary", "Accept");
     $content = $response->getBody();
     $hasXMLHeader = substr($content, 0, 5) == '<' . '?xml';
     // Fix base tag
     $content = preg_replace('/<base href="([^"]*)" \\/>/', '<base href="$1"><!--[if lte IE 6]></base><![endif]-->', $content);
     $content = preg_replace("#<\\?xml[^>]+\\?>\n?#", '', $content);
     $content = str_replace(array('/>', 'xml:lang', 'application/xhtml+xml'), array('>', 'lang', 'text/html'), $content);
     // Only replace the doctype in templates with the xml header
     if ($hasXMLHeader) {
         $content = preg_replace('/<!DOCTYPE[^>]+>/', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', $content);
     }
     $content = preg_replace('/<html xmlns="[^"]+"/', '<html ', $content);
     $response->setBody($content);
 }