/// <summary> /// Reads the response of the server. /// </summary> /// <returns>The data sent by the memcached server.</returns> /// <exception cref="T:System.InvalidOperationException">The server did not sent a response or an empty line was returned.</exception> /// <exception cref="T:Enyim.Caching.Memcached.MemcachedException">The server did not specified any reason just returned the string ERROR. - or - The server returned a SERVER_ERROR, in this case the Message of the exception is the message returned by the server.</exception> /// <exception cref="T:Enyim.Caching.Memcached.MemcachedClientException">The server did not recognize the request sent by the client. The Message of the exception is the message returned by the server.</exception> public static string ReadResponse(PooledSocket socket) { string response = TextSocketHelper.ReadLine(socket); if (log.IsDebugEnabled) { log.Debug("Received response: " + response); } if (String.IsNullOrEmpty(response)) { throw new MemcachedClientException("Empty response received."); } if (String.Compare(response, GenericErrorResponse, StringComparison.Ordinal) == 0) { throw new NotSupportedException("Operation is not supported by the server or the request was malformed. If the latter please report the bug to the developers."); } if (response.Length >= ErrorResponseLength) { if (String.Compare(response, 0, ClientErrorResponse, 0, ErrorResponseLength, StringComparison.Ordinal) == 0) { throw new MemcachedClientException(response.Remove(0, ErrorResponseLength)); } else if (String.Compare(response, 0, ServerErrorResponse, 0, ErrorResponseLength, StringComparison.Ordinal) == 0) { throw new MemcachedException(response.Remove(0, ErrorResponseLength)); } } return(response); }
protected override IOperationResult ReadResponse(PooledSocket socket) { this.result = new List <string>(); while (true) { string response = TextSocketHelper.ReadResponse(socket); if (string.Compare(response, "END", StringComparison.Ordinal) == 0) { break; } if (response.Length < 5 || string.Compare(response, 0, "ITEM ", 0, 5, StringComparison.Ordinal) != 0) { throw new MemcachedClientException("No ITEM response received.\r\n" + response); } this.result.Add(response); } ; var result = new CachedumpOperationResult(); return(result.Pass()); }
protected override IList <ArraySegment <byte> > GetBuffer() { var command = "stats cachedump " + this.Key + TextSocketHelper.CommandTerminator; return(TextSocketHelper.GetCommandBuffer(command)); }