Repository navigation
Conversation
The JSON formatters read only application/json and the XML formatter only application/xml. RFC 9457 problem details (application/problem+json and application/problem+xml) returned in error responses could not be read into ResponseErrorType, so HttpResponseException.ResponseObject was null. text/xml, which RFC 7303 registers with the same definition as application/xml, and vendor media types with a +json or +xml structured syntax suffix could not be read either. JsonFormatter and NewtonsoftJsonFormatter now read application/problem+json, and XmlFormatter reads text/xml and application/problem+xml; these are also advertised in the Accept header. Writing is unchanged. HttpContentFormatter gains CanReadMediaType, which CanRead calls to decide whether a media type is readable, and HasStructuredSyntaxSuffix. The JSON formatters override CanReadMediaType to read any +json media type and XmlFormatter any +xml media type. These are read but not advertised. The client still reads a response with the first formatter that can read it, so a formatter for a specific suffixed media type must be added before the JSON or XML formatter. Add MediaTypeNames.Application.ProblemJson and ProblemXml.
Delete the unused "using System.Net.Http;" from Kampute.HttpClient.HttpRequestMessagePropertyKeys.cs to clean up imports and avoid an unnecessary dependency on System.Net.Http (no types from that namespace are referenced).
NUnit 5.0.0 changed Assert.ThrowsAsync, Assert.CatchAsync and Assert.DoesNotThrowAsync to return a Task that must be awaited for the assertion to be evaluated. The test projects no longer compiled: NUnit.Analyzers reported each unawaited call as NUnit2059, and code that read the returned exception failed with CS1061. Await these assertions and make the enclosing tests async. The .NET Framework test project still uses NUnit 4.6.1 and is unchanged.
Bring the net48 test project to the test package versions of the other test projects: Microsoft.NET.Test.Sdk 18.10.1, NUnit 5.0.0 and NUnit3TestAdapter 6.3.0. NUnit 5 returns a Task from Assert.ThrowsAsync that must be awaited for the assertion to be evaluated. Await the three calls and make their tests async. The one inside Assert.EnterMultipleScope compiled without an await but would not have checked anything.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Read problem details, text/xml and suffixed media types
Error bodies in RFC 9457 problem-details format,
text/xml, and vendor+json/+xmlmedia types were rejected because each formatter only read its one base media type. WithResponseErrorTypeset, aproblem+jsonerror body was dropped andHttpResponseException.ResponseObjectcame backnull.Changes
JsonFormatterandNewtonsoftJsonFormatterreadapplication/problem+jsonand advertise it inAccept.XmlFormatterreadstext/xmlandapplication/problem+xmland advertises both inAccept.HttpContentFormatter.CanReadMediaType(protected virtual), whichCanReadnow calls, andHttpContentFormatter.HasStructuredSyntaxSuffix(protected static).+jsonmedia type, andXmlFormatterany+xmlmedia type. These are read but not added toAccept.MediaTypeNames.Application.ProblemJsonandProblemXml.