Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Add a TextResponse to easily return plain text HTTP responses #77

Closed
wants to merge 2 commits into from

Conversation

mnapoli
Copy link
Contributor

@mnapoli mnapoli commented Aug 4, 2015

Fixes #76

I did not add a charset as the HtmlResponse didn't have one. Maybe this is something to add? (see e.g. in symfony). I am very far from an expert in HTTP stuff, so I'm just bringing it up but I have no idea (and it should probably be done in a separate PR anyway).

## Text Responses

`Zend\Diactoros\Response\TextResponse` allows creating a plain text response. It sets the
`Content-Type` header to `text/html` by default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text/plain, not text/html.

@mnapoli
Copy link
Contributor Author

mnapoli commented Aug 5, 2015

Thanks @akrabat I've updated the commit.

@weierophinney weierophinney added this to the 1.2.0 milestone Aug 5, 2015
@weierophinney weierophinney self-assigned this Aug 5, 2015
@weierophinney
Copy link
Member

I did not add a charset as the HtmlResponse didn't have one. Maybe this is something to add?

Yes, please. :)

@weierophinney
Copy link
Member

Looks good; I'll wait for your feedback as to whether or not you want to add charset to this PR as well before merging, however.

@mnapoli
Copy link
Contributor Author

mnapoli commented Aug 5, 2015

Will do tomorrow! I'll add it on HtmlResponse too. UTF-8 by default?

@weierophinney
Copy link
Member

Will do tomorrow! I'll add it on HtmlResponse too.

Awesome!

UTF-8 by default?

Of course!

@mnapoli
Copy link
Contributor Author

mnapoli commented Aug 6, 2015

I've pushed a new commit setting UTF-8 for HTML and text responses (new commit as I think this is a separate change since it also applies to HtmlResponse).

From what I have read online (example: http://stackoverflow.com/a/19815111/245552) JSON is UTF-8 (mandatory) so there is no need for a charset.

weierophinney added a commit that referenced this pull request Aug 7, 2015
weierophinney added a commit that referenced this pull request Aug 7, 2015
@weierophinney
Copy link
Member

Merged to develop for release with 1.2.0. Thanks, @mnapoli !

@mnapoli mnapoli deleted the text-response branch August 8, 2015 08:07
@weierophinney weierophinney mentioned this pull request Aug 10, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants