Thanks cmickyb for a patch (Mantis#3089) that adds support for proxy in http requests

0.6.3-post-fixes
Dahlia Trimble 2009-02-06 01:25:59 +00:00
parent f8c372721b
commit 28820e6185
3 changed files with 39 additions and 0 deletions

View File

@ -90,6 +90,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
private int httpTimeout = 30000; private int httpTimeout = 30000;
private string m_name = "HttpScriptRequests"; private string m_name = "HttpScriptRequests";
private string m_proxyurl = "";
private string m_proxyexcepts = "";
// <request id, HttpRequestClass> // <request id, HttpRequestClass>
private Dictionary<UUID, HttpRequestClass> m_pendingRequests; private Dictionary<UUID, HttpRequestClass> m_pendingRequests;
private Scene m_scene; private Scene m_scene;
@ -152,6 +155,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
htc.httpTimeout = httpTimeout; htc.httpTimeout = httpTimeout;
htc.outbound_body = body; htc.outbound_body = body;
htc.response_headers = headers; htc.response_headers = headers;
htc.proxyurl = m_proxyurl;
htc.proxyexcepts = m_proxyexcepts;
lock (HttpListLock) lock (HttpListLock)
{ {
@ -232,6 +237,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
m_scene.RegisterModuleInterface<IHttpRequests>(this); 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>(); m_pendingRequests = new Dictionary<UUID, HttpRequestClass>();
} }
@ -285,6 +293,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
public Dictionary<string, string> response_headers; public Dictionary<string, string> response_headers;
public int status; public int status;
public string url; public string url;
public string proxyurl;
public string proxyexcepts;
public void process() public void process()
{ {
@ -316,6 +326,15 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
WebRequest.Create(url); WebRequest.Create(url);
request.Method = httpMethod; request.Method = httpMethod;
request.ContentType = httpMIMEType; 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) foreach (KeyValuePair<string, string> entry in response_headers)
request.Headers[entry.Key] = entry.Value; request.Headers[entry.Key] = entry.Value;

View File

@ -43,6 +43,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
private Scene m_scene; private Scene m_scene;
private IDynamicTextureManager m_textureManager; private IDynamicTextureManager m_textureManager;
private string m_proxyurl = "";
private string m_proxyexcepts = "";
#region IDynamicTextureRender Members #region IDynamicTextureRender Members
public string GetName() public string GetName()
@ -91,6 +95,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
{ {
m_scene = scene; m_scene = scene;
} }
m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
} }
public void PostInitialise() public void PostInitialise()
@ -121,6 +127,16 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
private void MakeHttpRequest(string url, UUID requestID) private void MakeHttpRequest(string url, UUID requestID)
{ {
WebRequest request = HttpWebRequest.Create(url); 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); RequestState state = new RequestState((HttpWebRequest) request, requestID);
// IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); // IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state);
request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state);

View File

@ -7,6 +7,10 @@
; (eg default is /opensimdir/crashes/*.txt or C:\opensim\crashes\*.txt) ; (eg default is /opensimdir/crashes/*.txt or C:\opensim\crashes\*.txt)
crash_dir = "crashes" 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 true if you are connecting your OpenSimulator regions to a grid
; Set this to false if you are running OpenSimulator in standalone mode ; Set this to false if you are running OpenSimulator in standalone mode
gridmode = false gridmode = false