Bug 17132 - HttpRequestMessage fails in Xam.iOS and Xam.Android but works in .NET 4.5
Summary: HttpRequestMessage fails in Xam.iOS and Xam.Android but works in .NET 4.5
Alias: None
Product: Class Libraries
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Reported: 2014-01-08 19:17 UTC by Jon Goldberger [MSFT]
Modified: 2014-01-13 08:48 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

.NET 4.5 test project (33.86 KB, application/zip)
2014-01-08 19:17 UTC, Jon Goldberger [MSFT]
Xam.iOS and Xam.Android test project (21.70 KB, application/zip)
2014-01-08 19:18 UTC, Jon Goldberger [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Comment 1 Jon Goldberger [MSFT] 2014-01-08 19:18:04 UTC
Created attachment 5797 [details]
Xam.iOS and Xam.Android test project
Comment 2 Jon Goldberger [MSFT] 2014-01-08 19:19:22 UTC
From case file:
"On Windows 8.1 with .NET 4.5, I can do the following (where hrm is an HttpRequestMessage)...

hrm.Headers.Add("Accept", "application/vnd.citrix.requesttokenresponse+xml, application/vnd.citrix.requesttokenchoices+xml");

On Xamarin.iOS, this is throwing a run-time System.FormatException.

Thoughts, please? I'm fine with altering my code in any way, so long as I can get the same effect on both platforms. Thanks!"

From me:
I confirmed this behavior. Test projects are attached.
Comment 3 Miguel de Icaza [MSFT] 2014-01-10 13:34:11 UTC
For now, split the two mime types into separate calls to Add like this:

hrm.Headers.Add("Accept", "application/vnd.citrix.requesttokenresponse+xml");
hrm.Headers.Add("Accept", "application/vnd.citrix.requesttokenchoices+xml");
Comment 4 Dominique Louis 2014-01-10 14:32:59 UTC
Another alternative is....

hrm.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.citrix.requesttokenresponse+xml"));
hrm.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.citrix.requesttokenchoices+xml"));
Comment 5 Marek Safar 2014-01-13 08:48:32 UTC
Fixed in mono master