wis3guy / HalClient.Net

A library that simplifies interaction with API's that respond with the "application\hal+json" media type.
Microsoft Public License
19 stars 21 forks source link

Version 1.2 is looking for Content-Type in wrong location #5

Closed gjorchard closed 9 years ago

gjorchard commented 9 years ago

I tried running the version you posted today. I did not work regardless of the setting of the new ParseBehavior. I looked into the HalClient code and found that it was not finding the "Content-Type" header. Looking at an HttpResponseMessage in Visual Studio I found it in the Content.Headers rather than Headers.

I change the line in ProcessResponseMessage from:

if (response.Headers.TryGetValues("Content-Type", out contentTypes))

to

if (response.Content.Headers.TryGetValues("Content-Type", out contentTypes))

and the code now appears to be working for me, though I haven't played with it much yet.

One suggestion for your updated documentation is to indicate what the default is for each of the settings.

Thanks for putting this new functionality in place!

wis3guy commented 9 years ago

Hmmm, how did that slip through my tests!?! Will look into this asap!

wis3guy commented 9 years ago

I have done several modifications, as well as fixed the described bug. Please give it another go and let me know how you proceed.

gjorchard commented 9 years ago

I tried my couple of applications and they work with the latest version. I am running with ParseBehavior set to Always and have tested with errors being returned.

I took a quick look at your change and was glad to see you have added the NotSupportedExceptions if there are problems with the ContentType header.

Good stuff!