fix recent bug on Urlmodule

master
UbitUmarov 2020-04-13 13:53:37 +01:00
parent d1f1324a2d
commit 745a469af8
1 changed files with 18 additions and 20 deletions

View File

@ -648,8 +648,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
try try
{ {
NameValueCollection headers = request.Headers;
//string uri_full = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; //string uri_full = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/";
int pos1 = uri.IndexOf("/");// /lslhttp int pos1 = uri.IndexOf("/");// /lslhttp
@ -696,31 +694,31 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
if (requestData.headers == null) if (requestData.headers == null)
requestData.headers = new Dictionary<string, string>(); requestData.headers = new Dictionary<string, string>();
foreach (DictionaryEntry header in headers) NameValueCollection headers = request.Headers;
if (headers.Count > 0)
{ {
string key = (string)header.Key; for(int i = 0; i < headers.Count; ++i)
string value = (string)header.Value; {
requestData.headers.Add(key, value); string name = headers.GetKey(i);
if (!string.IsNullOrEmpty(name))
requestData.headers[name] = headers[i];
}
} }
if(request.QueryString.Count > 0) NameValueCollection query = request.QueryString;
if (query.Count > 0)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
foreach (DictionaryEntry qs in request.QueryString) for (int i = 0; i < query.Count; ++i)
{ {
string key = (string)qs.Key; string key = query.GetKey(i);
string value = (string)qs.Value; if (string.IsNullOrEmpty(key))
if (key != "") sb.AppendFormat("{0}&", query[i]);
{
sb.AppendFormat("{0} = {1}&",key, value);
}
else else
{ sb.AppendFormat("{0} = {1}&", key, query[i]);
sb.AppendFormat("{0}&", value);
} }
} if (sb.Length > 1)
if(sb.Length > 1) sb.Remove(sb.Length - 1, 1);
sb.Remove(sb.Length -1,1);
requestData.headers["x-query-string"] = sb.ToString(); requestData.headers["x-query-string"] = sb.ToString();
} }
else else
@ -728,7 +726,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
//if this machine is behind DNAT/port forwarding, currently this is being //if this machine is behind DNAT/port forwarding, currently this is being
//set to address of port forwarding router //set to address of port forwarding router
requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; requestData.headers["x-remote-ip"] = request.RemoteIPEndPoint.Address.ToString();
requestData.headers["x-path-info"] = pathInfo; requestData.headers["x-path-info"] = pathInfo;
requestData.headers["x-script-url"] = url.url; requestData.headers["x-script-url"] = url.url;