protected override void WriteXmlHeader(Stream streamToFill)
 {
     streamToFill.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
     streamToFill.WriteLine("<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:g=\"http://base.google.com/ns/1.0\">");
     streamToFill.WriteLine(String.Format("<title>{0}</title>", _feedTitle));
     streamToFill.WriteLine(String.Format("<link rel=\"self\" href=\"{0}\"/>", _feedLink));
     streamToFill.WriteLine(String.Format("<updated>{0}</updated>", getFormatedDate(DateTime.Now)));
     streamToFill.WriteLine("<author>");
     streamToFill.WriteLine(String.Format("<name>{0}</name>", _feedAuthor));
     streamToFill.WriteLine("</author>");
     streamToFill.WriteLine(String.Format("<id>{0}</id>", _feedId));
 }
 public override void RenderCommand(Stream stream)
 {
     var header = string.Format("data {0}", _Bytes.Length);
     stream.WriteLine(header);
     stream.Write(_Bytes, 0, _Bytes.Length);
     stream.WriteLineFeed();
 }
        public void WriteTo(Stream stream)
        {
            var line = string.Format("{0} {1} {2}", Version, (int)StatusCode, StatusDescription);
            //Debug.WriteLine(line);
            stream.WriteLine(line);

            foreach (var pair in Headers)
            {
                if (pair.Key.ToLowerInvariant() == "proxy-connection")
                    continue;
                line = string.Format("{0}: {1}", pair.Key, pair.Value);
                stream.WriteLine(line);
            }
            //Debug.WriteLine(null);
            stream.WriteLine();
            //stream.Flush();
        }
        public override void RenderCommand(Stream stream)
        {
            var command = CommandName;
            if (!string.IsNullOrEmpty(Name))
                command += " " + Name;
            command += string.Format(" <{0}> ", Email);
            command += FormatDate(Date);

            stream.WriteLine(command);
        }
 public override void RenderCommand(Stream stream)
 {
     stream.WriteLine(string.Format("reset {0}", Reference));
     if (From != null)
     {
         stream.WriteString("from ");
         From.RenderMarkReference(stream);
         stream.WriteLineFeed();
     }
 }
        protected void RenderMarkCommand(Stream stream)
        {
            if (MarkId != null)
            {
                var command = string.Format("mark :{0}", MarkId);
                stream.WriteLine(command);

                _HasBeenRendered = true;
            }
        }
 protected override void WriteXmlHeader(Stream streamToFill)
 {
     streamToFill.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
     streamToFill.WriteLine("<rss version =\"2.0\" xmlns:g=\"http://base.google.com/ns/1.0\">");
     streamToFill.WriteLine("<channel>");
     streamToFill.WriteLine(String.Format("<title>{0}</title>", _feedTitle));
     streamToFill.WriteLine(String.Format("<description>{0}</description>", _feedDescription));
     streamToFill.WriteLine(String.Format("<link>{0}</link>", _feedLink));
 }
 public override void RenderCommand(Stream stream)
 {
     if (Blob != null)
     {
         stream.WriteString("M 644 ");
         Blob.RenderMarkReference(stream);
         stream.WriteString(string.Format(" \"{0}\"", Path));
         stream.WriteLineFeed();
     }
     else
     {
         stream.WriteLine(string.Format("M 644 inline \"{0}\"", Path));
         stream.RenderCommand(Data);
     }
 }
 public override void RenderCommand(Stream stream)
 {
     stream.WriteLine(string.Format("R {0} {1}", this.Source, this.Path));
 }
 protected override void WriteXmlFooter(Stream streamToFill)
 {
     streamToFill.WriteLine("</feed>");
 }
 protected virtual void WriteXmlHeader(Stream streamToFill)
 {
     streamToFill.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
     streamToFill.WriteLine("<root>");
 }
 protected virtual void WriteXmlFooter(Stream streamToFill)
 {
     streamToFill.WriteLine("</root>");
 }
        public override void RenderCommand(Stream stream)
        {
            foreach (var fc in FileCommands.OfType<FileModifyCommand>())
            {
                if (fc.Blob != null)
                    stream.RenderCommand(fc.Blob);
            }

            stream.WriteLine(string.Format("commit {0}", Reference));
            base.RenderMarkCommand(stream);

            if (Author != null)
                stream.RenderCommand(Author);
            stream.RenderCommand(Committer);
            stream.RenderCommand(CommitInfo);

            if (FromCommit != null)
            {
                stream.WriteString("from ");
                FromCommit.RenderMarkReference(stream);
                stream.WriteLineFeed();
            }

            foreach (var mc in MergeCommits)
            {
                stream.WriteString("merge ");
                mc.RenderMarkReference(stream);
                stream.WriteLineFeed();
            }

            foreach (var fc in FileCommands)
                stream.RenderCommand(fc);
            stream.WriteLineFeed();
        }
 protected override void WriteXmlFooter(Stream streamToFill)
 {
     streamToFill.WriteLine("</channel>");
     streamToFill.WriteLine("</rss>");
 }
 public override void RenderCommand(Stream stream)
 {
     stream.WriteLine(string.Format("D {0}", Path));
 }
Example #16
0
        private static bool CopyHttpStream(Stream fromStream, Stream toStream, string firstLine = "", string sslTunnelDomain="")
        {
            bool keepAlive = false; 
            var encoding = Encoding.UTF8;
            string method;
            string version;
            string url;

            using (var fromStreamReader = new BinaryReader(fromStream, encoding, true))
            using (var toStreamWriter = new BinaryWriter(toStream, encoding, true))
            {
                if (String.IsNullOrEmpty(firstLine))
                    firstLine = fromStream.ReadLine();

                if (!String.IsNullOrEmpty(sslTunnelDomain))
                {
                    //modify the path in the http request to include the domain
                    ParseHttpCommand(firstLine, out method, out url, out version);
                    //modify the forward address so it has complete URL 
                    firstLine = method + ' ' + "https://" + sslTunnelDomain + url + ' ' + version;
                    firstLine += "\r\n";
                    firstLine += "X-Forward-Secure: true";
                }
                LogMessage(string.Format(firstLine));
                toStream.WriteLine(firstLine);
                toStream.Flush();

                string line;
                int contentLength = 0;
                bool chunked = false;

                //copy the headers
                while (!String.IsNullOrEmpty(line = fromStreamReader.ReadLine()))
                {
                    if (line.StartsWith("Content-Length:", true, CultureInfo.CurrentCulture))
                        contentLength = int.Parse(line.Replace("Content-Length:", ""));
                    if (line.StartsWith("Transfer-Encoding: chunked", true, CultureInfo.CurrentCulture))
                        chunked = true;
                    if (line.StartsWith("Proxy-Connection: Keep-Alive", true, CultureInfo.CurrentCulture))
                        keepAlive = true;
                    toStreamWriter.WriteLine(line);
                }
                toStreamWriter.WriteLine();
                if (contentLength > 0)
                    toStreamWriter.Write(fromStreamReader.ReadBytes(contentLength));

                if(chunked)
                {
                    while (!String.IsNullOrEmpty(line = fromStreamReader.ReadLine()))
                    {
                        contentLength = int.Parse(line, System.Globalization.NumberStyles.HexNumber);
                        toStreamWriter.Write(fromStreamReader.ReadBytes(contentLength));
                        fromStreamReader.ReadLine();
                    }
                }
                toStreamWriter.Flush();
            }
            return keepAlive;
        }
 public override void RenderCommand(Stream stream)
 {
     stream.WriteLine("deleteall");
 }