Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Set request type before setting body #599

Merged
merged 2 commits into from

2 participants

@omeryar

having the body set before the type meant the body was encoded as html
no matter what the type actually is.

@nateabele
Owner

Why is every line in the class rewritten in the diff?

@omeryar

because I screwed up.
reverted old commit and added a fixed one.
Let me know if you prefer a new pull request.

@nateabele
Owner

Nope, the existing PR is fine. Just do us a favor and squash your commits so we can keep the history clean. :-)

The patch itself looks good. We'll get it merged in once one of us has a chance to add a failing test against the Service class (you're welcome to add one instead if you're so inclined). Thanks again for tracking this down!

@omeryar

squashed.

@omeryar omeryar updated testJsonPost to test 56a5ef4
new test would have failed before
59c1780
@omeryar

updated testJsonPost().
new test would have failed before 56a5ef4 with:

Exception thrown in -::join() on line 105
Array to string conversion

in lithium\net\http\Request::_encode()

@nateabele nateabele merged commit 9cb627c into UnionOfRAD:dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 28, 2012
  1. @omeryar
Commits on Aug 1, 2012
  1. @omeryar

    updated testJsonPost to test 56a5ef4

    omeryar authored
    new test would have failed before
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 6 deletions.
  1. +1 −1  net/http/Service.php
  2. +5 −5 tests/cases/net/http/ServiceTest.php
View
2  net/http/Service.php
@@ -216,8 +216,8 @@ protected function _request($method, $path, $data, $options) {
$request->method = $method = strtoupper($method);
$hasBody = in_array($method, array('POST', 'PUT'));
- $hasBody ? $request->body($data) : $request->query = $data;
$hasBody ? $request->type($options['type']) : null;
+ $hasBody ? $request->body($data) : $request->query = $data;
return $request;
}
}
View
10 tests/cases/net/http/ServiceTest.php
@@ -178,15 +178,15 @@ public function testDelete() {
public function testJsonPost() {
$http = new Service($this->_testConfig);
- $http->post('update.xml', array('status' => 'cool'), array('type' => 'json'));
+ $http->post('update.xml', array('status' => array('cool', 'awesome')), array('type' => 'json'));
$expected = join("\r\n", array(
'POST /update.xml HTTP/1.1',
'Host: localhost:80',
'Connection: Close',
'User-Agent: Mozilla/5.0',
'Content-Type: application/json',
- 'Content-Length: 17',
- '', '{"status":"cool"}'
+ 'Content-Length: 29',
+ '', '{"status":["cool","awesome"]}'
));
$result = (string) $http->last->request;
$this->assertEqual($expected, $result);
@@ -197,8 +197,8 @@ public function testJsonPost() {
'Connection: Close',
'User-Agent: Mozilla/5.0',
'Content-Type: application/json',
- 'Content-Length: 17',
- '', '{"status":"cool"}'
+ 'Content-Length: 29',
+ '', '{"status":["cool","awesome"]}'
));
$result = (string) $http->last->response;
$this->assertEqual($expected, $result);
Something went wrong with that request. Please try again.