Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

* StringOutput set proper ContentType #3919

Merged
merged 1 commit into from
Jan 19, 2016

Conversation

ryanbrandenburg
Copy link
Contributor

Fixes #3692

@@ -34,8 +34,12 @@ public override bool CanWriteResult(OutputFormatterCanWriteContext context)
// always return it as a text/plain format.
if (context.ObjectType == typeof(string) || context.Object is string)
{
context.ContentType = new StringSegment(SupportedMediaTypes[0]);
return true;
if (context.ContentType == null)
Copy link
Member

Choose a reason for hiding this comment

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

StringSegments can't be null.

@rynowak
Copy link
Member

rynowak commented Jan 13, 2016

Tests?

@rynowak
Copy link
Member

rynowak commented Jan 13, 2016

@ryanbrandenburg
Copy link
Contributor Author

🆙 📅

context.ContentType = new StringSegment(SupportedMediaTypes[0]);
if (!context.ContentType.HasValue)
{
context.ContentType = new StringSegment(SupportedMediaTypes[0]);
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we'd also include an charset here. Look at what the other formatters do

@rynowak
Copy link
Member

rynowak commented Jan 14, 2016

@ryanbrandenburg ryanbrandenburg force-pushed the rybrande/StringContentType branch from 8fcc538 to 0d0d935 Compare January 14, 2016 22:35
@ryanbrandenburg
Copy link
Contributor Author

🆙 📅 Added unit tests and set charset on default ContentType.

@@ -20,7 +19,7 @@ public StringOutputFormatter()
{
SupportedEncodings.Add(Encoding.UTF8);
SupportedEncodings.Add(Encoding.Unicode);
SupportedMediaTypes.Add("text/plain");
SupportedMediaTypes.Add("text/plain;charset=utf-8");
Copy link
Member

Choose a reason for hiding this comment

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

This isn't right. Look at what the other formatters do.

@ryanbrandenburg
Copy link
Contributor Author

🆙 📅

@rynowak
Copy link
Member

rynowak commented Jan 15, 2016

:shipit:

@ryanbrandenburg ryanbrandenburg force-pushed the rybrande/StringContentType branch 2 times, most recently from cf17778 to 285af4e Compare January 16, 2016 00:18
@ryanbrandenburg ryanbrandenburg force-pushed the rybrande/StringContentType branch from 285af4e to a229b20 Compare January 19, 2016 18:07
@ryanbrandenburg ryanbrandenburg merged commit a229b20 into dev Jan 19, 2016
@ryanbrandenburg ryanbrandenburg deleted the rybrande/StringContentType branch January 20, 2016 00:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants