i have strange problem webrequest in servicestack web application (hosted xsp on mono). seems registration of request modules works in strange way; using webrequest create http request, , failing because not able find creator "prefix" (http).
the exception seeing notsupportedexception
, , able track fact no creator registered http prefix (i hitting https://github.com/mono/mono/blob/master/mcs/class/system/system.net/webrequest.cs, around line 479)
edit: more details: notsupportedexception
thrown webrequest.getcreator
, uses url prefix key choose creator return; in case, httprequestcreator
. exception thrown because there no creator registered "http" prefix (actually, there no creators @ all).
so searched around little bit, dug mono sources, , found modules (or should be) added webrequestmodules section of system.web in 1 of various *.config files.
i looked @ machine.config file, , there is: system.net.httprequestcreator, system, version=4.0.0.0
looking @ webrequest mono sources seems prefixes added configuration(s) indeed, inside class static constructor (not choice, imho, still.. should work).
to test it, tried add httprequestcreator
system.net/webrequestmodules
in web.config
; loaded xsp/mono , results in duplicate key exception (which expected, since httprequestcreator should loaded, present in machine.config).
even stranger: if add mock handler http, this:
bool res = system.net.webrequest.registerprefix ("http", new myhttprequestcreator ()); debug.assert (res == false);
the assertion sometime pass... sometime not! (registerprefix returns "false" if creator same prefix registered; expect return false, not case! again, random)
when registration "fails" (i.e. returns false because "http" prefix registered) webrequest able create requests http. if calling registerprefix "wakes up" static constructor , let run.
i perplexed: seems race condition in execution of static constructor of webrequest, not make sense (static constructors protected runtime lock, iirc)
what missing? how solve, or work around problem? fault (misunderstanding or missing something) or mono bug, , therefore should submit it?
details:
mono --version mono jit compiler version 3.0.6 (debian 3.0.6+dfsg-1~exp1~pre1)
(possibly related, unanswered question: http protocol not supported in webrequest under mono)
Comments
Post a Comment