Skip to content

Commit

Permalink
Setting correct Content-Type for PATCH requests in net\http\Request.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Padron committed Sep 18, 2012
1 parent d0491b6 commit c49de93
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion net/http/Request.php
Expand Up @@ -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]);
Expand Down
12 changes: 12 additions & 0 deletions tests/cases/net/http/ServiceTest.php
Expand Up @@ -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');
Expand Down

0 comments on commit c49de93

Please sign in to comment.