Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ReceiveCommandResponseCallback()

void System.Net.CommandStream.ReceiveCommandResponseCallback ( ReceiveState state,
int bytesRead )
inlineprivateinherited

Definition at line 476 of file CommandStream.cs.

477 {
478 int completeLength = -1;
479 while (true)
480 {
481 int validThrough = state.ValidThrough;
482 if (_buffer.Length > 0)
483 {
484 state.Resp.StatusBuffer.Append(_buffer);
485 _buffer = string.Empty;
486 if (!CheckValid(state.Resp, ref validThrough, ref completeLength))
487 {
488 throw GenerateException(System.SR.net_ftp_protocolerror, WebExceptionStatus.ServerProtocolViolation, null);
489 }
490 }
491 else
492 {
493 if (bytesRead <= 0)
494 {
495 throw GenerateException(System.SR.net_ftp_protocolerror, WebExceptionStatus.ServerProtocolViolation, null);
496 }
497 char[] array = new char[_decoder.GetCharCount(state.Buffer, 0, bytesRead)];
498 int chars = _decoder.GetChars(state.Buffer, 0, bytesRead, array, 0, flush: false);
499 string text = new string(array, 0, chars);
500 state.Resp.StatusBuffer.Append(text);
501 if (!CheckValid(state.Resp, ref validThrough, ref completeLength))
502 {
503 throw GenerateException(System.SR.net_ftp_protocolerror, WebExceptionStatus.ServerProtocolViolation, null);
504 }
505 if (completeLength >= 0)
506 {
507 int num = state.Resp.StatusBuffer.Length - completeLength;
508 if (num > 0)
509 {
510 _buffer = text.Substring(text.Length - num, num);
511 }
512 }
513 }
514 if (completeLength >= 0)
515 {
516 break;
517 }
518 state.ValidThrough = validThrough;
519 try
520 {
521 if (_isAsync)
522 {
523 BeginRead(state.Buffer, 0, state.Buffer.Length, s_readCallbackDelegate, state);
524 return;
525 }
526 bytesRead = Read(state.Buffer, 0, state.Buffer.Length);
527 if (bytesRead == 0)
528 {
529 CloseSocket();
530 }
531 }
532 catch (IOException)
533 {
535 throw;
536 }
537 catch
538 {
539 throw;
540 }
541 }
542 string text2 = state.Resp.StatusBuffer.ToString();
543 state.Resp.StatusDescription = text2.Substring(0, completeLength);
544 if (System.Net.NetEventSource.Log.IsEnabled())
545 {
546 System.Net.NetEventSource.Info(this, $"Received response: {text2.Substring(0, completeLength - 2)}", "ReceiveCommandResponseCallback");
547 }
548 if (_isAsync)
549 {
550 if (state.Resp != null)
551 {
553 }
554 Stream stream = null;
556 {
558 }
559 }
560 }
ResponseDescription _currentResponseDescription
static readonly AsyncCallback s_readCallbackDelegate
bool PostReadCommandProcessing(ref Stream stream)
Exception GenerateException(string message, WebExceptionStatus status, Exception innerException)
virtual bool CheckValid(ResponseDescription response, ref int validThrough, ref int completeLength)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
override IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
static string net_ftp_protocolerror
Definition SR.cs:104
Definition SR.cs:7
int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
int GetCharCount(byte[] bytes, int index, int count)

References System.Net.CommandStream._buffer, System.Net.CommandStream._currentResponseDescription, System.Net.CommandStream._decoder, System.Net.CommandStream._isAsync, System.array, System.Net.NetworkStreamWrapper.BeginRead(), System.chars, System.Net.CommandStream.CheckValid(), System.Net.NetworkStreamWrapper.CloseSocket(), System.Net.CommandStream.ContinueCommandPipeline(), System.Net.CommandStream.GenerateException(), System.Text.Decoder.GetCharCount(), System.Text.Decoder.GetChars(), System.Net.NetEventSource.Info(), System.Net.NetEventSource.Log, System.Net.CommandStream.MarkAsRecoverableFailure(), System.SR.net_ftp_protocolerror, System.Net.CommandStream.PostReadCommandProcessing(), System.IO.Read, System.Net.CommandStream.s_readCallbackDelegate, System.state, System.stream, and System.text.

Referenced by System.Net.CommandStream.ReadCallback(), and System.Net.CommandStream.ReceiveCommandResponse().