Skip to content

Commit 2d383b4

Browse files
committed
[Network][Http] Add request setter version
1 parent fbfc9fa commit 2d383b4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/Network/Http/Request.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,21 @@ public function cookie($name, $value = null)
173173
}
174174
return $this;
175175
}
176+
177+
/**
178+
* Get/Set http version.
179+
*
180+
* @param string|null $version The http version.
181+
*
182+
* @return $this|string Either $this or the http version.
183+
*/
184+
public function version($version = null)
185+
{
186+
if ($version === null) {
187+
return parent::version();
188+
}
189+
190+
$this->_version = $version;
191+
return $this;
192+
}
176193
}

tests/TestCase/Network/Http/RequestTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,18 @@ public function testCookie()
119119
$result = $request->cookie('session');
120120
$this->assertEquals('123456', $result);
121121
}
122+
123+
/**
124+
* test version method.
125+
*
126+
* @return void
127+
*/
128+
public function testVersion()
129+
{
130+
$request = new Request();
131+
$result = $request->version('1.0');
132+
$this->assertSame($request, $request, 'Should return self');
133+
134+
$this->assertSame('1.0', $request->version());
135+
}
122136
}

0 commit comments

Comments
 (0)