protected void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            if (httpRequest.HttpMethod != "GET")
            {
                httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }

            NameValueCollection query = httpRequest.QueryString;
            string names   = query.GetOne("names");
            string psize   = query.GetOne("page_size");
            string pnumber = query.GetOne("page");

            if (string.IsNullOrEmpty(names) || names.Length < 3)
            {
                httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
                return;
            }

            int page_size;
            int page_number;

            try
            {
                page_size   = (string.IsNullOrEmpty(psize) ? 500 : Int32.Parse(psize));
                page_number = (string.IsNullOrEmpty(pnumber) ? 1 : Int32.Parse(pnumber));
            }
            catch
            {
                httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
                return;
            }
            // Full content request
            List <UserData> users = m_People.GetUserData(names, page_size, page_number);

            LLSDAvatarPicker osdReply = new LLSDAvatarPicker();

            osdReply.next_page_url = httpRequest.RawUrl;
            foreach (UserData u in users)
            {
                osdReply.agents.Array.Add(ConvertUserData(u));
            }

            string reply = LLSDHelpers.SerialiseLLSDReply(osdReply);

            httpResponse.RawBuffer   = Util.UTF8.GetBytes(reply);
            httpResponse.StatusCode  = (int)HttpStatusCode.OK;
            httpResponse.ContentType = "application/llsd+xml";
        }
Exemple #2
0
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            // Try to parse the texture ID from the request URL
            NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
            string names   = query.GetOne("names");
            string psize   = query.GetOne("page_size");
            string pnumber = query.GetOne("page");

            if (m_PeopleService == null)
            {
                return(FailureResponse(names, (int)System.Net.HttpStatusCode.InternalServerError, httpResponse));
            }

            if (string.IsNullOrEmpty(names) || names.Length < 3)
            {
                return(FailureResponse(names, (int)System.Net.HttpStatusCode.BadRequest, httpResponse));
            }

            m_log.DebugFormat("[AVATAR PICKER SEARCH]: search for {0}", names);

            int page_size   = (string.IsNullOrEmpty(psize) ? 500 : Int32.Parse(psize));
            int page_number = (string.IsNullOrEmpty(pnumber) ? 1 : Int32.Parse(pnumber));

            // Full content request
            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
            //httpResponse.ContentLength = ??;
            httpResponse.ContentType = "application/llsd+xml";

            List <UserData> users = m_PeopleService.GetUserData(names, page_size, page_number);

            LLSDAvatarPicker osdReply = new LLSDAvatarPicker();

            osdReply.next_page_url = httpRequest.RawUrl;
            foreach (UserData u in users)
            {
                osdReply.agents.Array.Add(ConvertUserData(u));
            }

            string reply = LLSDHelpers.SerialiseLLSDReply(osdReply);

            return(System.Text.Encoding.UTF8.GetBytes(reply));
        }