add to SynchronousRestFormsRequester a keepalive disable option, and make use of it on some friends conns

melanie
UbitUmarov 2016-11-23 19:30:55 +00:00
parent 82ed6bde6e
commit b3eda582ec
3 changed files with 9 additions and 13 deletions

View File

@ -1019,7 +1019,8 @@ namespace OpenSim.Framework
/// ///
/// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting /// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting
/// the request. You'll want to make sure you deal with this as they're not uncommon</exception> /// the request. You'll want to make sure you deal with this as they're not uncommon</exception>
public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs, IServiceAuth auth) public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs = -1,
IServiceAuth auth = null, bool keepalive = true)
{ {
int reqnum = WebUtil.RequestNumber++; int reqnum = WebUtil.RequestNumber++;
@ -1034,6 +1035,8 @@ namespace OpenSim.Framework
request.Method = verb; request.Method = verb;
if (timeoutsecs > 0) if (timeoutsecs > 0)
request.Timeout = timeoutsecs * 1000; request.Timeout = timeoutsecs * 1000;
if(!keepalive && request is HttpWebRequest)
((HttpWebRequest)request).KeepAlive = false;
if (auth != null) if (auth != null)
auth.AddAuthorization(request.Headers); auth.AddAuthorization(request.Headers);
@ -1125,16 +1128,6 @@ namespace OpenSim.Framework
return respstring; return respstring;
} }
public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs)
{
return MakeRequest(verb, requestUrl, obj, timeoutsecs, null);
}
public static string MakeRequest(string verb, string requestUrl, string obj)
{
return MakeRequest(verb, requestUrl, obj, -1);
}
public static string MakeRequest(string verb, string requestUrl, string obj, IServiceAuth auth) public static string MakeRequest(string verb, string requestUrl, string obj, IServiceAuth auth)
{ {
return MakeRequest(verb, requestUrl, obj, -1, auth); return MakeRequest(verb, requestUrl, obj, -1, auth);

View File

@ -158,7 +158,7 @@ namespace OpenSim.Services.Connectors.Friends
try try
{ {
string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, 15, null, false);
if (reply != string.Empty) if (reply != string.Empty)
{ {
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);

View File

@ -277,7 +277,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
{ {
reply = SynchronousRestFormsRequester.MakeRequest("POST", reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri, uri,
ServerUtils.BuildQueryString(sendData), 15); ServerUtils.BuildQueryString(sendData),
15,
null,
false);
} }
catch (Exception e) catch (Exception e)
{ {