Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
[zendframework/zendframework#5140] Adapt changes to actual master cha…
Browse files Browse the repository at this point in the history
…nges.

Adapt code to design changes added by zendframework/zendframework#5291 and zendframework/zendframework#5303
  • Loading branch information
Maks3w committed Oct 20, 2013
1 parent de1119e commit c38a124
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
6 changes: 2 additions & 4 deletions src/Header/ContentTransferEncoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,15 @@ class ContentTransferEncoding implements HeaderInterface
public static function fromString($headerLine)
{
$headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8');
list($name, $value) = explode(': ', $headerLine, 2);
list($name, $value) = GenericHeader::splitHeaderLine($headerLine);

// check to ensure proper header type for this factory
if (strtolower($name) !== 'content-transfer-encoding') {
throw new Exception\InvalidArgumentException('Invalid header line for Content-Transfer-Encoding string');
}

$transferEncoding = $value;

$header = new static();
$header->setTransferEncoding($transferEncoding);
$header->setTransferEncoding($value);

return $header;
}
Expand Down
22 changes: 1 addition & 21 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,27 +402,7 @@ public function setBody($body)
$parts = $this->body->getParts();
if (!empty($parts)) {
$part = array_shift($parts);
$partHeaders = $part->getHeadersArray();
$partHeadersFixed = array();
foreach($partHeaders as $key => $value) {
if(is_array($value) && isset($value[0])) {
switch($value[0]) {
case 'Content-Type':
$contentType = Header\ContentType::fromString('Content-Type: ' . $value[1]);
$headers->addHeader($contentType);
break;
case 'Content-Transfer-Encoding':
$contentTE = Header\ContentTransferEncoding::fromString('Content-Transfer-Encoding: ' . $value[1]);
$headers->addHeader($contentTE);
break;
default:
$partHeadersFixed[$key] = $value;
}
} else {
$partHeadersFixed[$key] = $value;
}
}
$headers->addHeaders($partHeadersFixed);
$headers->addHeaders($part->getHeadersArray());
}
return $this;
}
Expand Down

0 comments on commit c38a124

Please sign in to comment.