diff --git a/src/Header/ContentTransferEncoding.php b/src/Header/ContentTransferEncoding.php index 27f89886..0d20f011 100644 --- a/src/Header/ContentTransferEncoding.php +++ b/src/Header/ContentTransferEncoding.php @@ -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; } diff --git a/src/Message.php b/src/Message.php index d4632ea4..04c39a62 100644 --- a/src/Message.php +++ b/src/Message.php @@ -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; }