Fixing Content-Type bug for HTTP/1.1 POST Unary requests in Unity #41
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.
As described in #39 , there is a bug when trying to create Unary requests from Unity.
At the server side, the request content type will appear as
application/octet-stream
instead of the expectedapplication/grpc-web
which will not allow the GrpcWebSocketBridge middleware to execute properly because of this condition:GrpcWebSocketBridge/src/GrpcWebSocketBridge.AspNetCore/GrpcWebBridgeMiddleware.cs
Line 25 in 8e37d22
The reason for this problem seems to be the implementation of the HTTP handler set for versions higher than Unity 2018.1, that uses
UnityWebRequestHttpHandler
.In the implementation of
UnityWebRequestHttpHandler
, the Content Type seems to be set by the request accept header, but at no time in the creation of the request this header is set, instead the correct Content Type is set on the request content header "Content-Type".I changed the implementation of
UnityWebRequestHttpHandler
to use this header.