Bug 27352

Summary: HttpRequestMessage: adding Accept header with multiple values fails
Product: [Mono] Class Libraries Reporter: Alexander Köplinger <alex.koeplinger>
Component: System.Net.HttpAssignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: masafa, mono-bugs+mono
Priority: ---    
Version: master   
Target Milestone: Untriaged   
Hardware: All   
OS: All   
Tags: Is this bug a regression?: ---
Last known good build:

Description Alexander Köplinger 2015-02-24 09:29:29 UTC
Repro code:

>var request = new HttpRequestMessage();
>request.Headers.Add("Accept", "application/vnd.github.moondragon+json; charset=utf-8,application/vnd.github.v3+json; charset=utf-8");

This throws an exception on Mono 3.12 and Mono master as of today:
>System.FormatException: Invalid format.
>  at System.Net.Http.Headers.HttpHeaders.AddInternal (System.String name, IEnumerable`1 values, System.Net.Http.Headers.HeaderInfo headerInfo, Boolean ignoreInvalid) [0x0004c] in /tmp/buildd/mono-snapshot-20150224105158-20150224105158/mcs/class/System.Net.Http/System.Net.Http.Headers/HttpHeaders.cs:196 
>  at System.Net.Http.Headers.HttpHeaders.Add (System.String name, IEnumerable`1 values) [0x00011] in /tmp/buildd/mono-snapshot-20150224105158-20150224105158/mcs/class/System.Net.Http/System.Net.Http.Headers/HttpHeaders.cs:171 
>  at System.Net.Http.Headers.HttpHeaders.Add (System.String name, System.String value) [0x00000] in /tmp/buildd/mono-snapshot-20150224105158-20150224105158/mcs/class/System.Net.Http/System.Net.Http.Headers/HttpHeaders.cs:163 
>  at Test.Main () [0x00000] in <filename unknown>:0 

This looks similar to https://bugzilla.xamarin.com/show_bug.cgi?id=17132 and the workaround of splitting it into multiple Add() calls works here as well.
Comment 1 Marek Safar 2015-02-24 10:55:57 UTC
Fixed in master