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 async Task <FtpReply> GetProxyReplyAsync(FtpSocketStream stream, CancellationToken token = default(CancellationToken)) { FtpReply reply = new FtpReply(); string buf; if (!IsConnected) { throw new InvalidOperationException("No connection to the server has been established."); } stream.ReadTimeout = ReadTimeout; while ((buf = await stream.ReadLineAsync(Encoding, token)) != null) { Match m; this.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 = await stream.ReadLineAsync(Encoding, token)) != null) { this.LogLine(FtpTraceLevel.Info, buf); if (FtpExtensions.IsNullOrWhiteSpace(buf)) { break; } reply.InfoMessages += (buf + "\n"); } return(reply); }