[Mono-list] HttpWebRequest not beeing persistent when ask to..

Esben Laursen (rantek.dk) el at rantek.dk
Tue Jun 5 13:51:03 UTC 2012


Hi Guys,

I have a snip of code that looks like this:

_request = (HttpWebRequest)WebRequest.Create(_url);
_request.KeepAlive = true;
_request.Method = WebRequestMethods.Http.Post;
_request.ContentType = "text/plain";

_request.CookieContainer = CreateSiteAuthentication(_request);
_request.ContentLength = _data.Length;

using (StreamWriter postStream = new StreamWriter(_request.GetRequestStream(), Encoding.ASCII))
{
    postStream.Write(_data);
    postStream.Close();
}

HttpWebResponse response = (HttpWebResponse)_request.GetResponse();
response.Close();
CheckStatusAndSignalDone(response.StatusCode);

I have doing initialization of the class set the "ServicePointManager.DefaultConnectionLimit" to 10.

My problem is that when I run this under a Debian Squeze with Mono 2.6.7, every time a http post is done the client closes the connection and starts up a new session. If I run the same code under Windows then it starts up 10 sessions and uses that with persistent connections as I want.

Do you know if there is any configuration specially to mono that needs to be setup for http persistence (keep alive) or is this a bug in the framework?

Any ideas?

Cheers

Esben


More information about the Mono-list mailing list