aboutsummaryrefslogtreecommitdiff
path: root/RSSDP/HttpRequestParser.cs
diff options
context:
space:
mode:
authorMatt Montgomery <33811686+ConfusedPolarBear@users.noreply.github.com>2020-07-26 16:14:58 -0500
committerMatt Montgomery <33811686+ConfusedPolarBear@users.noreply.github.com>2020-07-26 16:14:58 -0500
commita40fe867762ee8b538848b164952d951c3534485 (patch)
tree747a24b766e9a66339edaa45433103095e735814 /RSSDP/HttpRequestParser.cs
parente2f16fc2551592541846c2bd34f27773f33aae7e (diff)
parent8ab800508bb140d8671125245a64c9d27adcad13 (diff)
Merge remote-tracking branch 'upstream/master' into quickconnect
Diffstat (limited to 'RSSDP/HttpRequestParser.cs')
-rw-r--r--RSSDP/HttpRequestParser.cs41
1 files changed, 22 insertions, 19 deletions
diff --git a/RSSDP/HttpRequestParser.cs b/RSSDP/HttpRequestParser.cs
index 3fc328b8c..4114195a6 100644
--- a/RSSDP/HttpRequestParser.cs
+++ b/RSSDP/HttpRequestParser.cs
@@ -9,17 +9,10 @@ namespace Rssdp.Infrastructure
/// </summary>
public sealed class HttpRequestParser : HttpParserBase<HttpRequestMessage>
{
-
- #region Fields & Constants
-
private readonly string[] ContentHeaderNames = new string[]
- {
- "Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified"
- };
-
- #endregion
-
- #region Public Methods
+ {
+ "Allow", "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified"
+ };
/// <summary>
/// Parses the specified data into a <see cref="HttpRequestMessage"/> instance.
@@ -41,14 +34,12 @@ namespace Rssdp.Infrastructure
finally
{
if (retVal != null)
+ {
retVal.Dispose();
+ }
}
}
- #endregion
-
- #region Overrides
-
/// <summary>
/// Used to parse the first line of an HTTP request or response and assign the values to the appropriate properties on the <paramref name="message"/>.
/// </summary>
@@ -56,18 +47,32 @@ namespace Rssdp.Infrastructure
/// <param name="message">Either a <see cref="HttpResponseMessage"/> or <see cref="HttpRequestMessage"/> to assign the parsed values to.</param>
protected override void ParseStatusLine(string data, HttpRequestMessage message)
{
- if (data == null) throw new ArgumentNullException(nameof(data));
- if (message == null) throw new ArgumentNullException(nameof(message));
+ if (data == null)
+ {
+ throw new ArgumentNullException(nameof(data));
+ }
+
+ if (message == null)
+ {
+ throw new ArgumentNullException(nameof(message));
+ }
var parts = data.Split(' ');
- if (parts.Length < 2) throw new ArgumentException("Status line is invalid. Insufficient status parts.", nameof(data));
+ if (parts.Length < 2)
+ {
+ throw new ArgumentException("Status line is invalid. Insufficient status parts.", nameof(data));
+ }
message.Method = new HttpMethod(parts[0].Trim());
Uri requestUri;
if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out requestUri))
+ {
message.RequestUri = requestUri;
+ }
else
+ {
System.Diagnostics.Debug.WriteLine(parts[1]);
+ }
if (parts.Length >= 3)
{
@@ -83,7 +88,5 @@ namespace Rssdp.Infrastructure
{
return ContentHeaderNames.Contains(headerName, StringComparer.OrdinalIgnoreCase);
}
-
- #endregion
}
}