int ParseHttpRequestHeader(Internal.RecvIO recvIO) { //start from pos0 int readpos = 0; int lim = recvIO.BytesTransferred - 1; int i = 0; for (; i <= lim; ++i) { //just read if (recvIO.ReadByte(i) == '\r' && recvIO.ReadByte(i + 1) == '\n') { //each line //translate if (i - readpos < 512) { //copy recvIO.CopyTo(readpos, tmpReadBuffer, i - readpos); //translate string line = Encoding.UTF8.GetString(tmpReadBuffer, 0, i - readpos); readpos = i + 2; i++; //skip \n //translate header *** if (line == "") { //complete http header parseState = HttpParsingState.Body; return readpos; } else { //parse header line AddReqHeader(line); } } else { //just skip? //skip too long line readpos = i + 2; i++; //skip \n } } } return readpos; }
internal override void ReadRDATA(Internal.ByteReader reader) { // The format of the data within a DNS TXT record is one or more // strings, packed together in memory without any intervening gaps // or padding bytes for word alignment. // // The format of each constituent string within the DNS TXT record is // a single length byte, followed by 0-255 bytes of text data. // TXT-DATA strings are not guaranteed to consist purely of ASCII printable // characters though this is usually the case. List<Datagram> strings = new List<Datagram>(); for (int total = 0; total < Base.RDLENGTH; ) { byte length = reader.ReadByte(); if (length > 0) { if (total + length >= Base.RDLENGTH) throw new InvalidResponseException( "Invalid length byte in TXT record: String data would exceed RDLENGTH."); strings.Add(reader.ReadBytes(length)); } total += (length + 1); } Strings = strings.ToArray(); }