private FtpReply GetProxyReply(FtpSocketStream stream)
        {
            var    reply = new FtpReply();
            string buf;

#if !CORE14
            lock (Lock) {
#endif
            if (!IsConnected)
            {
                throw new InvalidOperationException("No connection to the server has been established.");
            }

            stream.ReadTimeout = ReadTimeout;
            while ((buf = stream.ReadLine(Encoding)) != null)
            {
                Match m;

                LogLine(FtpTraceLevel.Info, buf);

                if ((m = Regex.Match(buf, @"^HTTP/.*\s(?<code>[0-9]{3}) (?<message>.*)$")).Success)
                {
                    reply.Code    = m.Groups["code"].Value;
                    reply.Message = m.Groups["message"].Value;
                    break;
                }

                reply.InfoMessages += buf + "\n";
            }

            // fixes #84 (missing bytes when downloading/uploading files through proxy)
            while ((buf = stream.ReadLine(Encoding)) != null)
            {
                LogLine(FtpTraceLevel.Info, buf);

                if (FtpExtensions.IsNullOrWhiteSpace(buf))
                {
                    break;
                }

                reply.InfoMessages += buf + "\n";
            }

#if !CORE14
        }
#endif

            return(reply);
        }
        private FtpReply GetProxyReply(FtpSocketStream stream)
        {
            FtpReply reply = new FtpReply();
            string   buf;

            lock (Lock) {
                if (!IsConnected)
                {
                    throw new InvalidOperationException("No connection to the server has been established.");
                }

                stream.ReadTimeout = ReadTimeout;
                while ((buf = stream.ReadLine(Encoding)) != null)
                {
                    Match m;

                    FtpTrace.WriteLine(buf);

                    if ((m = Regex.Match(buf, @"^HTTP/.*\s(?<code>[0-9]{3}) (?<message>.*)$")).Success)
                    {
                        reply.Code    = m.Groups["code"].Value;
                        reply.Message = m.Groups["message"].Value;
                        break;
                    }

                    reply.InfoMessages += string.Format("{0}\n", buf);
                }
            }

            return(reply);
        }