public void ParseOneField()
 {
     ByteString responseText = new ByteString("HTTP/1.1 200 OK\r\n" + 
                                               "Header1: Value1\r\n\r\n");
     HttpResponse response = new HttpResponse(responseText);
     Assert.AreEqual("Value1", response.Fields["Header1"]);
 }
 public void ParseContent()
 {
     ByteString responseText = new ByteString("HTTP/1.1 200 OK\r\n" +
                                               "Header1: Value1\r\n" +
                                               "Header2: Value2\r\n\r\n" +
                                               "content");
     HttpResponse response = new HttpResponse(responseText);
     Assert.AreEqual(new ByteString("content"), response.Content);
 }
 public TrackerResponse(ByteString responseText)
 {
     HttpResponse response = new HttpResponse(responseText);
     BenDecoder decoder = new BenDecoder(new MemoryStream(response.Content.ToBytes()));
     responseContent = decoder.ReadDictionary();
     
     if(IsSuccessful)
     {
         ByteString peers = responseContent["peers"] as ByteString;
         BinaryReader reader = new BinaryReader(new MemoryStream(peers.ToBytes()));
         for(int i = 0; i<peers.ToBytes().Length; i+=6)
         {
             peerList.Add(new PeerInfo(reader.ReadBytes(4), reader.ReadInt16()));
         }
     }
 }
 public void ParseStatusLine()
 {
     ByteString responseText = new ByteString("HTTP/1.1 200 OK\r\n\r\n");
     HttpResponse response = new HttpResponse(responseText);
     Assert.AreEqual("HTTP/1.1 200 OK", response.StausLine);
 }