Thanks cmickyb for a patch (Mantis#3089) that adds support for proxy in http requests
parent
f8c372721b
commit
28820e6185
|
@ -90,6 +90,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
|
|||
private int httpTimeout = 30000;
|
||||
private string m_name = "HttpScriptRequests";
|
||||
|
||||
private string m_proxyurl = "";
|
||||
private string m_proxyexcepts = "";
|
||||
|
||||
// <request id, HttpRequestClass>
|
||||
private Dictionary<UUID, HttpRequestClass> m_pendingRequests;
|
||||
private Scene m_scene;
|
||||
|
@ -152,6 +155,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
|
|||
htc.httpTimeout = httpTimeout;
|
||||
htc.outbound_body = body;
|
||||
htc.response_headers = headers;
|
||||
htc.proxyurl = m_proxyurl;
|
||||
htc.proxyexcepts = m_proxyexcepts;
|
||||
|
||||
lock (HttpListLock)
|
||||
{
|
||||
|
@ -232,6 +237,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
|
|||
|
||||
m_scene.RegisterModuleInterface<IHttpRequests>(this);
|
||||
|
||||
m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
|
||||
m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
|
||||
|
||||
m_pendingRequests = new Dictionary<UUID, HttpRequestClass>();
|
||||
}
|
||||
|
||||
|
@ -285,6 +293,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
|
|||
public Dictionary<string, string> response_headers;
|
||||
public int status;
|
||||
public string url;
|
||||
public string proxyurl;
|
||||
public string proxyexcepts;
|
||||
|
||||
public void process()
|
||||
{
|
||||
|
@ -316,6 +326,15 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
|
|||
WebRequest.Create(url);
|
||||
request.Method = httpMethod;
|
||||
request.ContentType = httpMIMEType;
|
||||
if (proxyurl.Length > 0)
|
||||
{
|
||||
if (proxyexcepts.Length > 0) {
|
||||
string[] elist = proxyexcepts.Split(';');
|
||||
request.Proxy = new WebProxy(proxyurl,true,elist);
|
||||
} else {
|
||||
request.Proxy = new WebProxy(proxyurl,true);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, string> entry in response_headers)
|
||||
request.Headers[entry.Key] = entry.Value;
|
||||
|
|
|
@ -43,6 +43,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
|
|||
private Scene m_scene;
|
||||
private IDynamicTextureManager m_textureManager;
|
||||
|
||||
private string m_proxyurl = "";
|
||||
private string m_proxyexcepts = "";
|
||||
|
||||
|
||||
#region IDynamicTextureRender Members
|
||||
|
||||
public string GetName()
|
||||
|
@ -91,6 +95,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
|
|||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
|
||||
m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
|
@ -121,6 +127,16 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
|
|||
private void MakeHttpRequest(string url, UUID requestID)
|
||||
{
|
||||
WebRequest request = HttpWebRequest.Create(url);
|
||||
if (m_proxyurl.Length > 0)
|
||||
{
|
||||
if (m_proxyexcepts.Length > 0) {
|
||||
string[] elist = m_proxyexcepts.Split(';');
|
||||
request.Proxy = new WebProxy(m_proxyurl,true,elist);
|
||||
} else {
|
||||
request.Proxy = new WebProxy(m_proxyurl,true);
|
||||
}
|
||||
}
|
||||
|
||||
RequestState state = new RequestState((HttpWebRequest) request, requestID);
|
||||
// IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state);
|
||||
request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state);
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
; (eg default is /opensimdir/crashes/*.txt or C:\opensim\crashes\*.txt)
|
||||
crash_dir = "crashes"
|
||||
|
||||
; Http proxy support for llHTTPRequest and dynamic texture loading
|
||||
HttpProxy = "http://proxy.com"
|
||||
HttpProxyExceptions = ".mydomain.com;localhost"
|
||||
|
||||
; Set this to true if you are connecting your OpenSimulator regions to a grid
|
||||
; Set this to false if you are running OpenSimulator in standalone mode
|
||||
gridmode = false
|
||||
|
|
Loading…
Reference in New Issue