pusher / pusher-websocket-dotnet

Pusher Channels Client Library for .NET
MIT License
112 stars 113 forks source link

Fix #78, #85 JsonReaderException in HttpAuthorizer #86

Closed damdo closed 4 years ago

damdo commented 4 years ago

This PR aims to fix #78 and fix #85, both highlighting a JsonReaderException happening in HttpAuthorizer.Authorize():

JsonReaderException: Unexpected character encountered while parsing value: S. Path '', line 0, position 0

where response.Content.ToString() returns a System.Net.Http.StreamContent instead of the expected String.

This is fixed by utilizing ReadAsStringAsync() to serialize the HTTP content to a string as an asynchronous operation followed by a .Result which waits for the operation to complete and fetches the String with the HTTP content from the returned task object.