Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: "XML parsing error: Hub reply does not define a root element #4075" #4223

Merged
merged 5 commits into from
Oct 5, 2018
Merged

Conversation

lAnubisl
Copy link
Contributor

@lAnubisl lAnubisl commented Oct 1, 2018

No description provided.

Copy link
Contributor

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

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

We'd want a more targeted fix than this I think. Happy to help get this PR to that point though! Let me know if I can help.

@@ -154,7 +154,7 @@ public Task ProcessRequest(IDictionary<string, object> environment)
environment.DisableResponseBuffering();

var response = new OwinResponse(environment);

response.ContentType = "text/html";
Copy link
Contributor

Choose a reason for hiding this comment

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

Hrm, I think text/html is not a great choice for this. Also, we do set the mime type correctly in some requests (see SendJsonResponse) so I'd rather narrow this to make sure we understand where the Content-Type is missing and add the correct Content-Type values there.

Copy link
Contributor Author

@lAnubisl lAnubisl Oct 3, 2018

Choose a reason for hiding this comment

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

@anurse

  1. In this particular place if you call response.ContentType just after constructor call it will respond "text/html" but "Content-Type" will not be added to the response until you set it explicitly. Don't ask me why.
  2. there are 2 places where ContentType is missing. But I think that all places which have a specific content type will just override default one. So I think that having default one is a good choice (you do want to have all response with "Content-Type" set don't you?)

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Don't ask me why.

This is because it is a convention that text/html is the default Content-Type. OwinResponse is using that value to indicate that there is no active Content-Type. However, as you noticed, some browsers dislike that and emit a warning.

2. So I think that having default one is a good choice

I don't think it's a good idea to have an inaccurate content type. I'd much prefer that we set it where we know what the content type is. Accidentally forgetting to set the content type yields an error message in the dev tools console which can easily be ignored and doesn't cause a funtional problem. Accidentally putting the wrong content type in place can yield functional problems. It's a matter of which is more dangerous to forget to do, and simply not setting the Content-Type is much less dangerous.

@dnfclas
Copy link

dnfclas commented Oct 4, 2018

CLA assistant check
All CLA requirements met.

@lAnubisl
Copy link
Contributor Author

lAnubisl commented Oct 4, 2018

@anurse Please review

Copy link
Contributor

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

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

Minor things to tweak then I'll go ahead an merge this in! Thanks for the fix!

};

transport.Object.ProcessRequest(transportConnection.Object).Wait();
response.VerifySet(r => r.ContentType = It.IsAny<string>(), "ContentType not set");
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you assert the specific content type? We're trying to avoid simple "was this property set" or "was this method called" test cases moving forward since they are brittle and don't test the actual desired outcome.

@@ -106,6 +106,7 @@ protected Task ProcessRequestCore(ITransportConnection connection)
}
else if (IsAbortRequest)
{
Context.Response.ContentType = "text/html";
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this text/plain?

@analogrelay analogrelay merged commit a0b4b4b into SignalR:master Oct 5, 2018
@analogrelay
Copy link
Contributor

Thanks for the contribution @lAnubisl !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants