public static byte[] ReadMultiByte(Stream stream) { byte length = ByteOp.ReadByte(stream); byte[] temp = new byte[length]; stream.Read(temp, 0, length); return(temp); }
public SkipOp(Stream input) : base(0) { Amount = ByteOp.ReadByte(input); // This is super hacky. Would recommend fixing very much. Probably. byte[] junk = new byte[Amount]; input.Read(junk, 0, Amount); }
public static Match ReadCompressionPair(Stream stream) { int encoded = (ByteOp.ReadByte(stream) << 8) | ByteOp.ReadByte(stream); uint length = (uint)(encoded & LENGTH_BITMASK); uint offset = (uint)((encoded & OFFSET_BITMASK) >> 5); return(new Match { Success = true, Length = length + LENGTH_DIFFERENCE, Offset = offset + OFFSET_DIFFERENCE }); }
public void WriteOps(Stream output, Queue <Op> ops) { Op[] outputOps = new Op[4]; while (ops.Count >= 4) { for (int x = 0; x < 4; x++) { outputOps[x] = ops.Dequeue(); } byte opCode = CombineOps(new byte[] { outputOps[0].OpCode, outputOps[1].OpCode, outputOps[2].OpCode, outputOps[3].OpCode }); ByteOp.WriteByte(output, opCode); foreach (Op op in outputOps) { op.Write(output); } } }
public HTTPResponse Parse(byte[] data) { if (header != null) { return(this); } var stringData = Encoding.UTF8.GetString(data); this.headerDataEnds = ByteOp.PatternFind(data, new Byte[] { 0x0d, 0x0a, 0x0d, 0x0a }); if (headerDataEnds == -1) { binaryBody = true; binaryData = data; binaryDataEnds = data.Length; return(this); } var headerString = Encoding.UTF8.GetString(ByteOp.SubArray(data, 0, headerDataEnds - 0)); this.binaryData = ByteOp.SubArray(data, headerDataEnds + 4, data.Length - headerDataEnds - 4); ParseHeader(headerString); ParseCookie(); GetBody(); return(this); }
public override void Write(Stream output) { ByteOp.WriteByte(output, Amount); }