private void TimeoutHandler(AsyncHttpRequest pRequest)
            {
                UUID sessionid = pRequest.AgentID;
                Hashtable eventsToSend = null;

                lock (m_eqLock)
                {
                    if (isQueueValid == false)
                        return;

                    if (m_Request == pRequest)
                    {
                        m_Request = null;
                        eventsToSend = GetEvents(pRequest);
                    }
                }

                if (eventsToSend != null)
                    pRequest.SendResponse(eventsToSend);
            }
Example #2
0
 private void TimeoutHandler(AsyncHttpRequest pRequest)
 {
     pRequest.SendResponse(ProcessEvents(pRequest, true));
 }
Example #3
0
        private void TimeoutHandler(AsyncHttpRequest pRequest)
        {
            UUID sessionid = pRequest.AgentID;

            lock (m_Connections)
            {
                ConsoleConnection connection = null;
                m_Connections.TryGetValue(sessionid, out connection);
                if (connection == null)
                    return;
                if (connection.request == pRequest)
                    connection.request = null;
            }

            pRequest.SendResponse(ProcessEvents(pRequest));
        }
Example #4
0
        public void AsyncHttpRequest(IHttpServer server, string path, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            UUID urlcode;
            if (UUID.TryParse(path, out urlcode))
                return;

            AsyncHttpRequest asyncRequest = 
                new AsyncHttpRequest(server, httpRequest, httpResponse, urlcode, TimeoutHandler, m_DefaultTimeout);

            UUID requestID = asyncRequest.RequestID;
            Hashtable request = asyncRequest.RequestData;

            string uri = request["uri"].ToString();
            bool is_ssl = uri.Contains("lslhttps");

            try
            {
                Hashtable headers = (Hashtable)request["headers"];
                //HTTP server code doesn't provide us with QueryStrings
                string queryString = "";

                int pos1 = uri.IndexOf("/");// /lslhttp
                int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
                int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/
                string pathInfo = uri.Substring(pos3);

                string url = URLFromURI(uri);
                UrlData urlData = null;

                lock (m_UrlMap)
                {
                    m_UrlMap.TryGetValue(url, out urlData);

                    // Returning NULL sends a 404 from the base server
                    if (urlData == null)
                        asyncRequest.SendResponse(server.SendHTML404(httpResponse));
                        
                }

                //for llGetHttpHeader support we need to store original URI here
                //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers 
                //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader

                RequestData requestData =
                    new RequestData
                    {
                        requestId = asyncRequest.RequestID,
                        polledRequest = asyncRequest,
                        requestDone = false,
                        startTime = Environment.TickCount,
                        uri = uri
                    };

                if (requestData.headers == null)
                    requestData.headers = new Dictionary<string, string>();

                // Copy in the headers, convert keys to lower case: See.
                // http://wiki.secondlife.com/wiki/LlGetHTTPHeader
                foreach (DictionaryEntry header in headers)
                {
                    string key = (string)header.Key;
                    string value = (string)header.Value;
                    requestData.headers.Add(key.ToLower(), value);
                }

                foreach (DictionaryEntry de in request)
                {
                    if (de.Key.ToString() == "querystringkeys")
                    {
                        String[] keys = (String[])de.Value;
                        foreach (String key in keys)
                        {
                            if (request.ContainsKey(key))
                            {
                                string val = (String)request[key];
                                queryString = queryString + key + "=" + val + "&";
                            }
                        }

                        if (queryString.Length > 1)
                            queryString = queryString.Substring(0, queryString.Length - 1);
                    }
                }

                //if this machine is behind DNAT/port forwarding, currently this is being
                //set to address of port forwarding router
                requestData.headers["x-remote-ip"] = httpRequest.RemoteIPEndPoint.ToString();
                requestData.headers["x-path-info"] = pathInfo;
                requestData.headers["x-query-string"] = queryString;
                requestData.headers["x-script-url"] = urlData.url;

                lock (m_RequestMap)
                {
                    m_RequestMap.Add(requestID, requestData);
                }

                lock (m_UrlMap)
                {
                    urlData.requests.Add(requestID);
                }

                urlData.engine.PostScriptEvent(urlData.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); 
            }
            catch (Exception we)
            {
                m_log.Warn("[HttpRequestHandler]: http-in request failed");
                m_log.Warn(we.Message);
                m_log.Warn(we.StackTrace);

                asyncRequest.SendResponse(server.SendHTML500(httpResponse));
            }
        }
            private void SendFetchTimeout(AsyncHttpRequest pRequest, ulong age)
            {
                var timeout = new Hashtable();
                timeout["response_binary"] = new byte[0];
                timeout["int_response_code"] = 504; //gateway timeout

                m_log.WarnFormat("[CAPS/INVENTORY]: HandleAsyncFetchInventoryDescendents: Request was too old to be processed {0}ms for {1}", age, m_agentID);

                pRequest.SendResponse(timeout);
            }