Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

3.0 - Add shortcut accessors for `json` and `xml` to Network\Http\Response #1093

Merged
merged 2 commits into from Jan 29, 2013

Conversation

Projects
None yet
2 participants
Owner

markstory commented Jan 28, 2013

This makes reading/dealing with xml & json easier. It also leaves room to add other commonly used data types in the future if necessary.

markstory added some commits Jan 28, 2013

Add shortcut accessors for `json` and `xml`
This makes reading/dealing with xml & json easier. It also leaves room
to add other commonly used data types in the future if necessary.
Fix loading invalid XML
Add tests for invalid XML + invalid JSON.
Member

jrbasso commented Jan 28, 2013

Simple and useful 👍

Member

jrbasso commented Jan 28, 2013

What you think in create a method to use these methods to return the body parsed based on the content-type header?

Ie, if the response contains the content-type header defined as application/json, you can call $response->parsedBody() and get the json array. Same for the xml.

Owner

markstory commented Jan 28, 2013

The body() method already has a way to parse a callable in and parse the results, would this replace that or be in addition to?

Member

jrbasso commented Jan 28, 2013

I didn't notice body has a parse as parameter. If you are getting a parsed body you usually know what is the expected content, so maybe the parsedBody is an overkill.

Owner

markstory commented Jan 29, 2013

I thought accepting a callable would leave things more open ended for situations where people didn't just need xml/json. Since there don't seem to be any objections to this I'll merge it in.

markstory added a commit that referenced this pull request Jan 29, 2013

Merge pull request #1093 from markstory/3.0-json-xml-responses
3.0 - Add shortcut accessors for `json` and `xml` to Network\Http\Response

@markstory markstory merged commit 520bcd3 into cakephp:3.0 Jan 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment