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

[Fixes #1791]Remove XML formatter from defaults #1798

Closed
wants to merge 3 commits into from

Conversation

kichalla
Copy link
Member

if (options.IgnoreBrowserAcceptHeader
&& HasWildCardMediaAndSubMediaType(sortedAcceptHeaderMediaTypes))
{
ignoreAcceptHeader = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's typically better to use positive logic, so perhaps rename to RespectBrowserAcceptHeader and respectAcceptHeader respectively

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@Tratcher
Copy link
Member

The strongly typed headers PR is incoming and it's going to massively conflict with this one.

/// <param name="options"></param>
public static void AddXmlDataContractSerializerFormatter(this MvcOptions options)
{
options.OutputFormatters.Add(
Copy link
Contributor

Choose a reason for hiding this comment

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

@kulmugdha you will need to base your changes on top of this

@kichalla
Copy link
Member Author

Updated /cc: @yishaigalatzer ...I did not address the comment related to a lazy property as it has problems with in-memory tests...will discuss with you in person..

@Tratcher
Copy link
Member

Rebase and try again....

IOutputFormatter selectedFormatter = null;

bool respectAcceptHeader = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

var

{
// Arrange
var objectResult = new ObjectResult(new Person() { Name = "John" });
objectResult.ContentTypes.Add(MediaTypeHeaderValue.Parse("application/xml"));
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not see the produces attribute being used directly here. ( I know it will result in the same thing), I suggest use produces in a functional test to cover this scenario and change the test name to reflect what it actually tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Added some functional tests for this

@harshgMSFT
Copy link
Contributor

@kichalla
Copy link
Member Author

Updated. @harshgMSFT @yishaigalatzer

var server = TestServer.Create(_provider, _app);
var client = server.CreateClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*", 0.2));
Copy link
Contributor

Choose a reason for hiding this comment

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

the default accept headers from the browser come without a quality factor, our tests should reflect it.

Copy link
Member Author

Choose a reason for hiding this comment

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

actually they do come with quality factor in many cases...example below:

Chrome:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

IE:
Accept: text/html, application/xhtml+xml, */*

Firefox:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Safari:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Opera:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

@harshgMSFT
Copy link
Contributor

fix comments then :shipit: from me.

@yishaigalatzer
Copy link
Contributor

:shipit: when comments are addressed

@kichalla
Copy link
Member Author

Commit: 02f4ca9

@kichalla kichalla closed this Jan 16, 2015
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.

None yet

5 participants