Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add ContentTransferEncoding Headers

  • Loading branch information...
commit 52dd72bbd738bd7fe9221dd6d9a731b663a81266 1 parent eecbe14
@prolic authored
View
52 library/Zend/Http/Header/ContentTransferEncoding.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Http
+ */
+
+namespace Zend\Http\Header;
+
+/**
+ * @throws Exception\InvalidArgumentException
+ * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 @todo find section
+ */
+class ContentTransferEncoding implements HeaderInterface
+{
+
+ public static function fromString($headerLine)
+ {
+ $header = new static();
+
+ list($name, $value) = explode(': ', $headerLine, 2);
+
+ // 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: "' . $name . '"');
+ }
+
+ // @todo implementation details
+ $header->value = $value;
+
+ return $header;
+ }
+
+ public function getFieldName()
+ {
+ return 'Content-Transfer-Encoding';
+ }
+
+ public function getFieldValue()
+ {
+ return $this->value;
+ }
+
+ public function toString()
+ {
+ return 'Content-Transfer-Encoding: ' . $this->getFieldValue();
+ }
+
+}
View
51 tests/ZendTest/Http/Header/ContentTransferEncodingTest.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Http
+ */
+
+namespace ZendTest\Http\Header;
+
+use Zend\Http\Header\ContentTransferEncoding;
+
+class ContentTransferEncodingTest extends \PHPUnit_Framework_TestCase
+{
+
+ public function testContentTransferEncodingFromStringCreatesValidContentTransferEncodingHeader()
+ {
+ $contentTransferEncodingHeader = ContentTransferEncoding::fromString('Content-Transfer-Encoding: xxx');
+ $this->assertInstanceOf('Zend\Http\Header\HeaderInterface', $contentTransferEncodingHeader);
+ $this->assertInstanceOf('Zend\Http\Header\ContentTransferEncoding', $contentTransferEncodingHeader);
+ }
+
+ public function testContentTransferEncodingGetFieldNameReturnsHeaderName()
+ {
+ $contentTransferEncodingHeader = new ContentTransferEncoding();
+ $this->assertEquals('Content-Transfer-Encoding', $contentTransferEncodingHeader->getFieldName());
+ }
+
+ public function testContentTransferEncodingGetFieldValueReturnsProperValue()
+ {
+ $this->markTestIncomplete('ContentTransferEncoding needs to be completed');
+
+ $contentTransferEncodingHeader = new ContentTransferEncoding();
+ $this->assertEquals('xxx', $contentTransferEncodingHeader->getFieldValue());
+ }
+
+ public function testContentTransferEncodingToStringReturnsHeaderFormattedString()
+ {
+ $this->markTestIncomplete('ContentTransferEncoding needs to be completed');
+
+ $contentTransferEncodingHeader = new ContentTransferEncoding();
+
+ // @todo set some values, then test output
+ $this->assertEmpty('Content-Transfer-Encoding: xxx', $contentTransferEncodingHeader->toString());
+ }
+
+ /** Implmentation specific tests here */
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.