private void ParseBody() { _continuation = false; if (_contentLength > 0) { var endIndex = _position + _contentLength; if (_currentResponseTextLength < endIndex) { if (_contentQueue.Count == 0) { _responseText = Compact(); throw new OutOfContentException(); } _responseText = Compact() + _contentQueue.Dequeue(); ParseBody(); return; } _body = Body.From(_responseText.Substring(_position, endIndex)); _position += _contentLength; } else { _body = Body.Empty; } NextStep(); }
private bool ParseBody() { if (_bodyOnly) { _contentLength = _responseText.Length; } _continuation = false; if (_contentLength > 0) { var endIndex = _position + _contentLength; if (_currentResponseTextLength < endIndex) { if (_contentQueue.Count == 0) { _responseText = Compact(); return(true); } _responseText = Compact() + _contentQueue.Dequeue(); ParseBody(); return(false); } _body = Body.From(_responseText.Substring(_position, endIndex - _position)); _position += _contentLength; } else { _body = Body.Empty; } NextStep(); return(false); }
public Request WithBody(string body) => new Request(Method, Uri, Version, Headers, Body.From(body));
public static Response Of(Version version, ResponseStatus statusCode, Headers <ResponseHeader> headers, byte[] entity) => new Response(version, statusCode, headers, Body.From(entity));
public static Response Of(ResponseStatus statusCode, Headers <ResponseHeader> headers, string entity) => new Response(Version.Http1_1, statusCode, headers, Body.From(entity));
public static Response Of(Version version, ResponseStatus statusCode, byte[] entity) => new Response(version, statusCode, Http.Headers.Empty <ResponseHeader>(), Body.From(entity));
public static Response Of(ResponseStatus statusCode, string entity) => new Response(Version.Http1_1, statusCode, Http.Headers.Empty <ResponseHeader>(), Body.From(entity));