remove excess garbage

This commit is contained in:
UbitUmarov
2020-04-10 22:52:25 +01:00
parent 6fea9dafaf
commit 1c6d454691
15 changed files with 104 additions and 516 deletions

View File

@@ -26,9 +26,12 @@
*/
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Reflection;
using System.Text;
using System.Net;
using System.Net.Sockets;
using log4net;
@@ -636,18 +639,18 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
return response;
}
public void HttpRequestHandler(UUID requestID, Hashtable request)
public void HttpRequestHandler(UUID requestID, OSHttpRequest request)
{
lock (request)
{
string uri = request["uri"].ToString();
string uri = request.RawUrl;
bool is_ssl = uri.Contains("lslhttps");
try
{
Hashtable headers = (Hashtable)request["headers"];
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 pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
@@ -656,8 +659,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
string uri_tmp = uri.Substring(0, pos3 + 1);
//HTTP server code doesn't provide us with QueryStrings
string pathInfo;
string queryString;
queryString = "";
pathInfo = uri.Substring(pos3);
@@ -676,6 +678,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
else
{
//m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString());
request.InputStream.Dispose();
return;
}
@@ -699,38 +702,34 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
string value = (string)header.Value;
requestData.headers.Add(key, value);
}
foreach (DictionaryEntry de in request)
if(request.QueryString.Count > 0)
{
if (de.Key.ToString() == "querystringkeys")
StringBuilder sb = new StringBuilder();
foreach (DictionaryEntry qs in request.QueryString)
{
System.String[] keys = (System.String[])de.Value;
foreach (String key in keys)
string key = (string)qs.Key;
string value = (string)qs.Value;
if (key != "")
{
if (request.ContainsKey(key))
{
string val = (String)request[key];
if (key != "")
{
queryString = queryString + key + "=" + val + "&";
}
else
{
queryString = queryString + val + "&";
}
sb.AppendFormat("{0} = {1}&",key, value);
}
else
{
sb.AppendFormat("{0}&", value);
}
if (queryString.Length > 1)
queryString = queryString.Substring(0, queryString.Length - 1);
}
if(sb.Length > 1)
sb.Remove(sb.Length -1,1);
requestData.headers["x-query-string"] = sb.ToString();
}
else
requestData.headers["x-query-string"] = String.Empty;
//if this machine is behind DNAT/port forwarding, currently this is being
//set to address of port forwarding router
requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"];
requestData.headers["x-path-info"] = pathInfo;
requestData.headers["x-query-string"] = queryString;
requestData.headers["x-script-url"] = url.url;
//requestData.ev = new ManualResetEvent(false);
@@ -744,10 +743,18 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
m_RequestMap.Add(requestID, url);
}
url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() });
string requestBody;
if (request.InputStream.Length > 0)
{
using (StreamReader reader = new StreamReader(request.InputStream, Encoding.UTF8))
requestBody = reader.ReadToEnd();
}
else
requestBody = string.Empty;
//send initial response?
// Hashtable response = new Hashtable();
request.InputStream.Dispose();
url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request.HttpMethod, requestBody });
return;