Bug 27352 - HttpRequestMessage: adding Accept header with multiple values fails
Summary: HttpRequestMessage: adding Accept header with multiple values fails
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Net.Http (show other bugs)
Version: master
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Reported: 2015-02-24 09:29 UTC by Alexander Köplinger
Modified: 2015-02-24 10:55 UTC (History)
2 users (show)

See Also:
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

Note You need to log in before you can comment on or make changes to this bug.