public void Read() { iReader.ReadFlush(); uint count = 0; while (true) { byte[] line = Ascii.Trim(iReader.ReadUntil(Ascii.kAsciiLf)); int bytes = line.Length; if (bytes == 0) { if (count == 0) continue; // a blank line before first header - ignore (RFC 2616 section 4.1) iWriter.WriteFlush(); return; } if (Ascii.IsWhitespace(line[0])) continue; // a line starting with spaces is a continuation line Parser parser = new Parser(line); if (count == 0) { // status EVersion version = Http.Version(parser.Next()); uint code; try { code = Ascii.Uint(parser.Next()); } catch (AsciiError) { throw new HttpError(); } byte[] temp = Ascii.Trim(parser.Remaining()); string reason = Encoding.UTF8.GetString(temp, 0, temp.Length); Status status = new Status(code, reason); iWriter.WriteStatus(status, version); } else { // header byte[] field = parser.Next(Ascii.kAsciiColon); byte[] value = Ascii.Trim(parser.Remaining()); iWriter.WriteHeader(field, value); } count++; } }
public void Read() { iReader.ReadFlush(); uint count = 0; while (true) { byte[] line = Ascii.Trim(iReader.ReadUntil(Ascii.kAsciiLf)); Logger.InfoFormat("ReaderResponse {0}", Encoding.UTF8.GetString(line, 0, line.Length)); int bytes = line.Length; if (bytes == 0) { if (count == 0) continue; // a blank line before first header - ignore (RFC 2616 section 4.1) return; } if (Ascii.IsWhitespace(line[0])) continue; // a line starting with spaces is a continuation line Parser parser = new Parser(line); if (count == 0) { // status byte[] version = parser.Next(); byte[] code = parser.Next(); byte[] description = Ascii.Trim(parser.Remaining()); ProcessStatus(version, code, description); } else { // header byte[] field = parser.Next(Ascii.kAsciiColon); byte[] value = Ascii.Trim(parser.Remaining()); ProcessHeader(field, value); } count++; } }
public void Read() { iReader.ReadFlush(); uint count = 0; while (true) { byte[] line = Ascii.Trim(iReader.ReadUntil(Ascii.kAsciiLf)); int bytes = line.Length; if (bytes == 0) { if (count == 0) { continue; // a blank line before first header - ignore (RFC 2616 section 4.1) } iWriter.WriteFlush(); return; } if (Ascii.IsWhitespace(line[0])) continue; // a line starting with spaces is a continuation line Parser parser = new Parser(line); if (count == 0) { // method byte[] method = parser.Next(); byte[] uri = parser.Next(); byte[] version = Ascii.Trim(parser.Remaining()); iWriter.WriteMethod(method, uri, Http.Version(version)); } else { // header byte[] field = parser.Next(Ascii.kAsciiColon); byte[] value = Ascii.Trim(parser.Remaining()); iWriter.WriteHeader(field, value); } count++; } }