Example #1
0
 public void StreamCompleteTo(Stream S)
 {
     if (httpBody != null)
     {
         if (httpBody.IsLoaded)
         {
             byte[]       response = this.GetBytes();
             MemoryStream MS       = new MemoryStream(response);
             MS.CopyTo(S);
             MS.Flush();
             MS.Close();
         }
         else
         {
             string nchead = this.GetNoContentHeader();
             nchead += Instruction.ContentType(httpBody.Format);
             nchead += Instruction.ContentLength(httpBody.GetSize());
             byte[] headerbytes = Encoding.UTF8.GetBytes(nchead + HTTP.Newline);
             S.Write(headerbytes, 0, headerbytes.Length);
             httpBody.StreamTo(S);
         }
     }
     else
     {
         string       ncr = this.GetNoContentHeader() + Instruction.ContentLength(0) + HTTP.Newline;
         MemoryStream MS  = new MemoryStream(Encoding.UTF8.GetBytes(ncr));
         MS.CopyTo(S);
         MS.Flush();
         MS.Close();
     }
 }
Example #2
0
        protected bool SaveFile(string urlpath, IStreamableContent isc)
        {
            string fullpath = Path.Combine(AssetSubdir, urlpath);

            if (File.Exists(fullpath))
            {
                return(false);
            }
            else
            {
                using (FileStream FS = File.Create(fullpath)) {
                    isc.StreamTo(FS);
                }
                return(true);
            }
        }