Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add ContentTransferEncoding Headers #3314

Merged
merged 1 commit into from

2 participants

@prolic

No description provided.

@weierophinney weierophinney was assigned
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#3314] Add Content-Transfer-Encoding to HeaderLoader
- Added entry for new header
25575fd
@weierophinney weierophinney merged commit 52dd72b into from
@weierophinney

I added the new header type to the HeaderLoader on merge as well.

@prolic prolic deleted the branch
@katalonec katalonec referenced this pull request from a commit in katalonec/zf2
@weierophinney weierophinney Merge branch 'feature/3314' into develop
Close #3314
95c1120
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#3314] Add Content-Transfer-Encoding to HeaderLoader
- Added entry for new header
3f666c0
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'feature/3314' into develop
Close #3314
7e32c8c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 30, 2012
  1. @prolic
This page is out of date. Refresh to see the latest.
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 */
+
+}
Something went wrong with that request. Please try again.