Commit bb960354 authored by Brickner_cp's avatar Brickner_cp

HTTP

parent 40180aa4
......@@ -155,22 +155,22 @@ namespace PcapDotNet.Packets.Test
"\r\n" +
"5\r\n" +
"This \r\n" +
"3\r\n" +
"3;Extension\r\n" +
"is \r\n" +
"4\r\n" +
"the \r\n" +
"4\r\n" +
"body\r\n" +
"a;Extension=Value\r\n" +
"the 123456\r\n" +
"A;Extension=\"Quoted \\\" Value\"\r\n" +
"body 12345\r\n" +
"0\r\n",
HttpVersion.Version11, 200, "OK", new HttpHeader(new HttpTransferEncodingField("chunked")),
"5\r\n" +
"This \r\n" +
"3\r\n" +
"3;Extension\r\n" +
"is \r\n" +
"4\r\n" +
"the \r\n" +
"4\r\n" +
"body\r\n" +
"a;Extension=Value\r\n" +
"the 123456\r\n" +
"A;Extension=\"Quoted \\\" Value\"\r\n" +
"body 12345\r\n" +
"0\r\n");
TestHttpResponse("HTTP/1.1 200 OK\r\n" +
......@@ -227,6 +227,8 @@ namespace PcapDotNet.Packets.Test
Assert.IsFalse(http.IsResponse, "IsResponse " + httpString);
Assert.AreEqual(expectedVersion, http.Version, "Version " + httpString);
Assert.AreEqual(expectedHeader, http.Header, "Header " + httpString);
if (expectedHeader != null)
Assert.AreEqual(expectedHeader.ToString(), http.Header.ToString(), "Header " + httpString);
HttpRequestDatagram request = (HttpRequestDatagram)http;
Assert.AreEqual(expectedMethod, request.Method, "Method " + httpString);
......@@ -246,6 +248,8 @@ namespace PcapDotNet.Packets.Test
Assert.IsTrue(http.IsResponse, "IsResponse " + httpString);
Assert.AreEqual(expectedVersion, http.Version, "Version " + httpString);
Assert.AreEqual(expectedHeader, http.Header, "Header " + httpString);
if (expectedHeader != null)
Assert.IsNotNull(http.Header.ToString());
HttpResponseDatagram response = (HttpResponseDatagram)http;
Assert.AreEqual(expectedStatusCode, response.StatusCode, "StatusCode " + httpString);
......
......@@ -11,22 +11,22 @@ namespace PcapDotNet.Packets.Http
}
// UPALPHA
public static bool IsUpAlpha(this byte value)
{
return value >= AsciiBytes.UpperA && value <= AsciiBytes.UpperZ;
}
// public static bool IsUpAlpha(this byte value)
// {
// return value >= AsciiBytes.UpperA && value <= AsciiBytes.UpperZ;
// }
// LOALPHA
public static bool IsLowerAlpha(this byte value)
{
return value >= AsciiBytes.LowerA && value <= AsciiBytes.LowerZ;
}
// public static bool IsLowerAlpha(this byte value)
// {
// return value >= AsciiBytes.LowerA && value <= AsciiBytes.LowerZ;
// }
// ALPHA
public static bool IsAlpha(this byte value)
{
return value.IsUpAlpha() || value.IsLowerAlpha();
}
// public static bool IsAlpha(this byte value)
// {
// return value.IsUpAlpha() || value.IsLowerAlpha();
// }
// DIGIT
public static bool IsDigit(this byte value)
......
......@@ -297,58 +297,6 @@ namespace PcapDotNet.Packets.Http
return this;
}
public HttpParser CommaSeparated<T>(Func<T> commaSeparatedParsing, out List<T> commaSeparated)
{
commaSeparated = new List<T>();
bool more = true;
while (Success && more)
{
commaSeparated.Add(commaSeparatedParsing());
SkipLws();
more = false;
while (IsNext(AsciiBytes.Comma))
{
++_offset;
more = true;
SkipLws();
}
}
if (!Success)
commaSeparated = null;
return this;
}
public HttpTransferCoding TransferCoding()
{
string codingName;
Token(out codingName);
List<HttpParameter> parameters = new List<HttpParameter>();
while (Success && IsNext(AsciiBytes.Semicolon))
{
++_offset;
HttpParameter parameter;
Parameter(out parameter);
}
return Success ? new HttpTransferCoding(codingName, parameters.AsReadOnly()) : null;
}
public HttpParser Parameter(out HttpParameter parameter)
{
string attribute;
Token(out attribute).Bytes(AsciiBytes.EqualsSign);
Datagram value;
if (IsNext(AsciiBytes.DoubleQuotationMark))
QuotedString(out value);
else
Token(out value);
parameter = Success ? new HttpParameter(attribute, value) : null;
return this;
}
public HttpParser QuotedString(out Datagram quotedString)
{
quotedString = null;
......
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