Bug 27386 - HttpClient doesn't honor BaseAddress with the Get*Async methods
Summary: HttpClient doesn't honor BaseAddress with the Get*Async methods
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Net.Http (show other bugs)
Version: unspecified
Hardware: PC Other
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Reported: 2015-02-24 21:32 UTC by Cole Mickens
Modified: 2015-02-26 21:28 UTC (History)
2 users (show)

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


Description Cole Mickens 2015-02-24 21:32:14 UTC

I had to make this change because it seems that Mono's HttpClient uses SendAsync, which eventually winds up in CreateWebRequest. While HttpClient's SendAsync is aware of BaseAddress, HttpClientHandler's CreateWebRequest is not, and thus creates a new request object that is lacking the base address at the front of the request uri.

Work around is simple... I don't know enough about HttpClientHandler, but I'm wondering if CreateWebRequest should take BaseAddress into account and either set an appropriate value on the constructed HttpWebRequest, or add it to the request uri during construction.

Comment 1 Marek Safar 2015-02-25 02:43:41 UTC
It works for me with mono master and it should work with mono 3.12 as well. Relevant code is at https://github.com/mono/mono/blob/master/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs#L250
Comment 2 Cole Mickens 2015-02-25 02:59:12 UTC
The test that I referenced, was passing under .NET CLR but was failing under mono 3.12 until I added the indicated work around.

The error received was this one:
Comment 3 Marek Safar 2015-02-25 03:02:33 UTC
That's different issue, could you track down what the values of BaseAddress and request uri were in the failing case?
Comment 4 Cole Mickens 2015-02-25 03:04:21 UTC
Here's more information, showing mono 3.12 and my test, with the workaround

Comment 6 Marek Safar 2015-02-25 03:11:40 UTC
I can reproduce it now
Comment 7 Marek Safar 2015-02-25 06:32:44 UTC
Fixed in master and mono 4.0
Comment 8 Cole Mickens 2015-02-26 21:28:26 UTC
I can confirm it's fixed on master. Thanks for the fast turn around.

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