Permalink
Browse files

[Http] Adding helper DSL to compare filtered HTTP headers with actual…

… HTTP headers. Adding more coverage to CurlHandle so that the actual HTTP requests being sent are being checked. Fixing EntityEnclosingRequests so that the Content-Type is not removed when setting the body of a request. This allows a custom Content-Type to be specified in a factory method.
  • Loading branch information...
1 parent 7aa5084 commit c563d98bb2ba51b1b50a4f83faabb9a7b72d4193 @mtdowling mtdowling committed Jan 26, 2012
Showing with 5 additions and 7 deletions.
  1. +4 −6 Message/EntityEnclosingRequest.php
  2. +1 −1 Message/Request.php
View
10 Message/EntityEnclosingRequest.php
@@ -39,7 +39,7 @@ public function __construct($method, $url, $headers = array())
*/
public function __toString()
{
- return parent::__toString()
+ return parent::__toString()
. (count($this->getPostFields()) ? $this->postFields : $this->body);
}
@@ -61,11 +61,9 @@ public function setBody($body, $contentType = null, $tryChunkedTransfer = false)
{
$this->body = EntityBody::factory($body);
$this->removeHeader('Content-Length');
-
+
if ($contentType) {
$this->setHeader('Content-Type', $contentType);
- } else {
- $this->removeHeader('Content-Type');
}
if ($tryChunkedTransfer) {
@@ -120,7 +118,7 @@ public function getPostFields()
{
return $this->postFields->getAll();
}
-
+
/**
* Returns an associative array of POST field names and file paths
*
@@ -181,7 +179,7 @@ public function addPostFiles(array $files)
if (is_numeric($key)) {
$key = 'file';
}
-
+
$found = ($file[0] == '@')
? is_readable(substr($file, 1))
: is_readable($file);
View
2 Message/Request.php
@@ -815,7 +815,7 @@ protected function changedHeader($action, $keyOrArray)
if (in_array('Cookie', $keys)) {
if ($action == 'set') {
$this->cookie = Cookie::factory($this->getHeader('Cookie'));
- } else {
+ } else if ($this->cookie) {
$this->cookie->clear();
}
}

0 comments on commit c563d98

Please sign in to comment.