Closed mikedld closed 4 years ago
I think adding a flag in AspNetCoreRpcServerHandler
to switch the behavior should solve the problem.
Sounds good to me, as this would also preserve current behavior for users that don't care that much.
After thinking this over, I've decided to go with virtual method instead of using flags, so any user can do whatever customizations on the status code.
And since we are focusing on the implementation of JSON-RPC 2.0, I'll make that as the default behavior. Not sure whether there are many downstream users consuming this ASP.NET Core package, as I've actually spotted a bug in the implementation 😂
Thanks for a swift fix!
The code that determines the HTTP status code seems to only follow the 1.2 spec:
https://github.com/CXuesong/JsonRpc.Standard/blob/2e8cf27fb6b249e6b1f40b8378fc3b26aba44fd6/JsonRpc.AspNetCore/AspNetCoreRpcServerHandler.cs#L97-L111
2.0 spec states that
And then gives particular examples where both responses containing "result" and "error" return with HTTP status of 200.
Content-Type
header value is not up to the spec either, being set toapplication/json-rpc
(per 1.2 spec) and notapplication/json
. This one could be worked around by adjusting theAspNetCoreRpcServerHandler.ResponseContentType
property.