This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
* StringOutput set proper ContentType #3919
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ryanbrandenburg
force-pushed
the
rybrande/StringContentType
branch
from
January 13, 2016 00:43
873adec
to
c7148d6
Compare
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringSegment
s can't be null.
Tests? |
⌚ |
🆙 📅 |
context.ContentType = new StringSegment(SupportedMediaTypes[0]); | ||
if (!context.ContentType.HasValue) | ||
{ | ||
context.ContentType = new StringSegment(SupportedMediaTypes[0]); |
There was a problem hiding this comment.
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
⌚ |
ryanbrandenburg
force-pushed
the
rybrande/StringContentType
branch
from
January 14, 2016 22:35
8fcc538
to
0d0d935
Compare
🆙 📅 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"); |
There was a problem hiding this comment.
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
force-pushed
the
rybrande/StringContentType
branch
2 times, most recently
from
January 16, 2016 00:18
cf17778
to
285af4e
Compare
ryanbrandenburg
force-pushed
the
rybrande/StringContentType
branch
from
January 19, 2016 18:07
285af4e
to
a229b20
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3692