Esempio n. 1
0
        internal override Response GetResponse()
        {
            Response response;

            switch (_code)
            {
            case HttpStatusCodes.SuccessCreated: {
                response = new Response(_code);
                return(response);
            }

            case HttpStatusCodes.SuccessMultistatus: {
                String str;
                try {
                    str = FileManager.GetInstanse().GetDirInfo(_mFileName).Exists
                                    ? PropFindHelper.GetFilesPropInDir(_mFileName, 0)
                                    : PropFindHelper.GetFilesProp(_mFileName);
                    response = new Response(HttpStatusCodes.SuccessMultistatus);
                } catch (DirectoryNotFoundException) {
                    str      = "";
                    response = new Response(HttpStatusCodes.ClientErrorNotFound);
                }
                Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(str));
                response.SetContentLength(stream.Length);
                response.SetData(stream);
                response.AddHeaderValue("Content-Type", "application/xml; charset=\"utf-8\"");
                return(response);
            }

            default:
                throw new Exception("Bad code " + _code);
            }
        }
Esempio n. 2
0
        public void GetProp()
        {
            FileManager.Init("");
            const string fileName = "test.txt";
            var          file     = File.Create(fileName);

            file.Close();
            var curRes = PropFindHelper.GetFilesProp(fileName);
            //<d:status>HTTP/1.1 200 OK</d:status>
            var pos = curRes.IndexOf("<d:status>HTTP/1.1 200 OK</d:status>", StringComparison.Ordinal);

            Assert.AreEqual(true, pos > 0);
        }
        internal override Response GetResponse()
        {
            Response response;
            String   str;

            try {
                str = FileManager.GetInstanse().GetDirInfo(_mPath).Exists ?
                      PropFindHelper.GetFilesPropInDir(_mPath, _mDepth) : PropFindHelper.GetFilesProp(_mPath);
                response = new Response(HttpStatusCodes.SuccessMultistatus);
                Logger.Trace(str);
            } catch (DirectoryNotFoundException) {
                str      = "";
                response = new Response(HttpStatusCodes.ClientErrorNotFound);
            }
            Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(str));

            response.SetContentLength(stream.Length);
            response.SetData(stream);
            response.AddHeaderValue("Content-Type", "application/xml; charset=\"utf-8\"");
            return(response);
        }