Commit 9dc319a6 authored by Brickner_cp's avatar Brickner_cp

HTTP

parent f7b62ff8
......@@ -68,7 +68,7 @@ namespace PcapDotNet.Core.Test
[TestMethod]
public void ComparePacketsToWiresharkTest()
{
for (int i = 0; i != 100; ++i)
for (int i = 0; i != 10; ++i)
{
// Create packets
List<Packet> packets = new List<Packet>(CreateRandomPackets(200));
......
......@@ -74,6 +74,8 @@ namespace PcapDotNet.Packets.Test
HttpRequestLayer httpRequestLayer = (HttpRequestLayer)httpLayer;
HttpRequestDatagram httpRequestDatagram = (HttpRequestDatagram)httpDatagram;
Assert.AreEqual(httpRequestLayer.Method, httpRequestDatagram.Method);
if (httpRequestLayer.Method != null)
Assert.AreEqual(httpRequestLayer.Method.KnownMethod, httpRequestDatagram.Method.KnownMethod);
Assert.AreEqual(httpRequestLayer.Uri, httpRequestDatagram.Uri);
}
else
......
......@@ -42,14 +42,15 @@ namespace PcapDotNet.Packets.Http
string fieldValueString = HttpRegex.GetString(fieldValue);
Match match = _regex.Match(fieldValueString);
if (!match.Success)
{
while (!match.Success && fieldValueString.Length > 0)
{
fieldValueString = fieldValueString.Substring(0, fieldValueString.Length - 1);
match = _regex.Match(fieldValueString);
}
return;
}
// {
// while (!match.Success && fieldValueString.Length > 0)
// {
// fieldValueString = fieldValueString.Substring(0, fieldValueString.Length - 1);
// match = _regex.Match(fieldValueString);
// }
// return;
// }
MediaType = match.Groups[MediaTypeGroupName].Captures.Cast<Capture>().First().Value;
MediaSubType = match.Groups[MediaSubTypeGroupName].Captures.Cast<Capture>().First().Value;
......
......@@ -74,11 +74,6 @@ namespace PcapDotNet.Packets.Http
return stringBuilder.ToString();
}
public HttpField(string name, IEnumerable<byte> value)
: this(name, value.ToArray())
{
}
public HttpField(string name, IList<byte> value)
:this(name, value.AsReadOnly())
{
......@@ -89,26 +84,6 @@ namespace PcapDotNet.Packets.Http
Name = name;
Value = value;
}
// public static HttpField Create(string name, byte[] value)
// {
// switch (name)
// {
// general-header
// case "Cache-Control":
// return new HttpCommaSeparatedField(name, value);
// case "Connection":
// case "Date":
// case "Pragma":
// case "Trailer":
// case "Transfer-Encoding":
// case "Upgrade":
// case "Via":
// case "Warning":
// break;
// }
//
// return new HttpField(name);
// }
public string Name { get; private set; }
public ReadOnlyCollection<byte> Value { get; private set; }
......
......@@ -44,10 +44,10 @@ namespace PcapDotNet.Packets.Http
return GetString(buffer, 0, buffer.Length);
}
public static byte[] GetBytes(string pattern)
{
return _encoding.GetBytes(pattern);
}
// public static byte[] GetBytes(string pattern)
// {
// return _encoding.GetBytes(pattern);
// }
public static Regex Build(string pattern)
{
......@@ -106,11 +106,6 @@ namespace PcapDotNet.Packets.Http
return Build(string.Format("(?<{0}>{1})", captureName, regex));
}
public static Regex MatchStart(Regex regex)
{
return Build(string.Format("^{0}", regex));
}
public static Regex MatchEntire(Regex regex)
{
return Build(string.Format("^{0}$", regex));
......
......@@ -25,7 +25,6 @@ namespace PcapDotNet.Packets.Http
{
}
public bool Equals(HttpTransferEncodingField other)
{
return other != null &&
......@@ -51,21 +50,17 @@ namespace PcapDotNet.Packets.Http
internal HttpTransferEncodingField(byte[] fieldValue)
: base(Name, fieldValue)
{
// string str = "\"h2ÇõX{âDv¼¯Ñ•)ËX?´ÈÔ\"";
// string str = "\"h2ÇõX{âDv¼¯Ñ)\"";
// Match tmpMatch = HttpRegex.QuotedString.Match(str);
// Console.WriteLine(tmpMatch.Success);
string fieldValueString = HttpRegex.GetString(fieldValue);
Match match = _regex.Match(fieldValueString);
if (!match.Success)
{
while (!match.Success && fieldValueString.Length > 0)
{
fieldValueString = fieldValueString.Substring(0, fieldValueString.Length - 1);
match = _regex.Match(fieldValueString);
}
return;
// while (!match.Success && fieldValueString.Length > 0)
// {
// fieldValueString = fieldValueString.Substring(0, fieldValueString.Length - 1);
// match = _regex.Match(fieldValueString);
// }
// return;
}
SetTransferCodings(match.GroupCapturesValues(RegexTransferCodingGroupName).ToArray());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment