Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Setting correct Content-Type for PATCH requests in net\http\Request.

  • Loading branch information...
commit c49de93466f866e4871b60ea48486d1c9575107d 1 parent d0491b6
@ppadron ppadron authored
Showing with 13 additions and 1 deletion.
  1. +1 −1  net/http/Request.php
  2. +12 −0 tests/cases/net/http/ServiceTest.php
View
2  net/http/Request.php
@@ -230,7 +230,7 @@ public function to($format, array $options = array()) {
$data = $auth::encode($options['username'], $options['password'], $data);
$this->headers('Authorization', $auth::header($data));
}
- if (in_array($options['method'], array('POST', 'PUT'))) {
+ if (in_array($options['method'], array('POST', 'PUT', 'PATCH'))) {
$media = $this->_classes['media'];
if ($type = $media::type($this->_type)) {
$this->headers('Content-Type', $type['content'][0]);
View
12 tests/cases/net/http/ServiceTest.php
@@ -261,6 +261,18 @@ public function testPatchMethod() {
$this->assertEqual('someData=someValue', $result->body());
}
+ public function testPatchWithJson() {
+ $http = new Service($this->_testConfig);
+ $response = $http->patch(
+ 'some-path/stuff',
+ array('someData' => 'someValue'),
+ array('return' => 'response', 'type' => 'json')
+ );
+ $result = $http->last->request;
+ $this->assertEqual('{"someData":"someValue"}', $result->body());
+ $this->assertEqual('application/json', $result->headers['Content-Type']);
+ }
+
public function testMagicMethod() {
$http = new Service($this->_testConfig);
$response = $http->magic('some-path/stuff');
Please sign in to comment.
Something went wrong with that request. Please try again.