aboutsummaryrefslogtreecommitdiff
path: root/RSSDP/HttpResponseParser.cs
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2019-01-10 19:54:18 -0500
committerGitHub <noreply@github.com>2019-01-10 19:54:18 -0500
commit15c89d281e29578a752dd9828e12e6fa243621a8 (patch)
tree49ad7b46cb06c844affe835e5ed7b8d87deebf4a /RSSDP/HttpResponseParser.cs
parent3d867c2c46cec39b669bb8647efef677f32b8a8d (diff)
parentbd169e4fd4f5586ab8dad323a520cbcc10de54fe (diff)
Merge pull request #506 from hawken93/linting
Removing tabs and trailing whitespace
Diffstat (limited to 'RSSDP/HttpResponseParser.cs')
-rw-r--r--RSSDP/HttpResponseParser.cs159
1 files changed, 79 insertions, 80 deletions
diff --git a/RSSDP/HttpResponseParser.cs b/RSSDP/HttpResponseParser.cs
index 8ecb944c2..cbd5517b8 100644
--- a/RSSDP/HttpResponseParser.cs
+++ b/RSSDP/HttpResponseParser.cs
@@ -8,82 +8,82 @@ using System.Threading.Tasks;
namespace Rssdp.Infrastructure
{
- /// <summary>
- /// Parses a string into a <see cref="System.Net.Http.HttpResponseMessage"/> or throws an exception.
- /// </summary>
- public sealed class HttpResponseParser : HttpParserBase<System.Net.Http.HttpResponseMessage>
- {
-
- #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
-
- /// <summary>
- /// Parses the specified data into a <see cref="System.Net.Http.HttpResponseMessage"/> instance.
- /// </summary>
- /// <param name="data">A string containing the data to parse.</param>
- /// <returns>A <see cref="System.Net.Http.HttpResponseMessage"/> instance containing the parsed data.</returns>
- public override HttpResponseMessage Parse(string data)
- {
- System.Net.Http.HttpResponseMessage retVal = null;
- try
- {
- retVal = new System.Net.Http.HttpResponseMessage();
-
- Parse(retVal, retVal.Headers, data);
-
- return retVal;
- }
- catch
- {
- if (retVal != null)
- retVal.Dispose();
-
- throw;
- }
- }
-
- #endregion
-
- #region Overrides Methods
-
- /// <summary>
- /// Returns a boolean indicating whether the specified HTTP header name represents a content header (true), or a message header (false).
- /// </summary>
- /// <param name="headerName">A string containing the name of the header to return the type of.</param>
- /// <returns>A boolean, true if th specified header relates to HTTP content, otherwise false.</returns>
- protected override bool IsContentHeader(string headerName)
- {
- return ContentHeaderNames.Contains(headerName, StringComparer.OrdinalIgnoreCase);
- }
-
- /// <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>
- /// <param name="data">The first line of the HTTP message to be parsed.</param>
- /// <param name="message">Either a <see cref="System.Net.Http.HttpResponseMessage"/> or <see cref="System.Net.Http.HttpRequestMessage"/> to assign the parsed values to.</param>
- protected override void ParseStatusLine(string data, HttpResponseMessage message)
- {
- if (data == null) throw new ArgumentNullException("data");
- if (message == null) throw new ArgumentNullException("message");
-
- var parts = data.Split(' ');
- if (parts.Length < 2) throw new ArgumentException("data status line is invalid. Insufficient status parts.", "data");
-
- message.Version = ParseHttpVersion(parts[0].Trim());
-
- int statusCode = -1;
- if (!Int32.TryParse(parts[1].Trim(), out statusCode))
- throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", "data");
-
- message.StatusCode = (HttpStatusCode)statusCode;
+ /// <summary>
+ /// Parses a string into a <see cref="System.Net.Http.HttpResponseMessage"/> or throws an exception.
+ /// </summary>
+ public sealed class HttpResponseParser : HttpParserBase<System.Net.Http.HttpResponseMessage>
+ {
+
+ #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
+
+ /// <summary>
+ /// Parses the specified data into a <see cref="System.Net.Http.HttpResponseMessage"/> instance.
+ /// </summary>
+ /// <param name="data">A string containing the data to parse.</param>
+ /// <returns>A <see cref="System.Net.Http.HttpResponseMessage"/> instance containing the parsed data.</returns>
+ public override HttpResponseMessage Parse(string data)
+ {
+ System.Net.Http.HttpResponseMessage retVal = null;
+ try
+ {
+ retVal = new System.Net.Http.HttpResponseMessage();
+
+ Parse(retVal, retVal.Headers, data);
+
+ return retVal;
+ }
+ catch
+ {
+ if (retVal != null)
+ retVal.Dispose();
+
+ throw;
+ }
+ }
+
+ #endregion
+
+ #region Overrides Methods
+
+ /// <summary>
+ /// Returns a boolean indicating whether the specified HTTP header name represents a content header (true), or a message header (false).
+ /// </summary>
+ /// <param name="headerName">A string containing the name of the header to return the type of.</param>
+ /// <returns>A boolean, true if th specified header relates to HTTP content, otherwise false.</returns>
+ protected override bool IsContentHeader(string headerName)
+ {
+ return ContentHeaderNames.Contains(headerName, StringComparer.OrdinalIgnoreCase);
+ }
+
+ /// <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>
+ /// <param name="data">The first line of the HTTP message to be parsed.</param>
+ /// <param name="message">Either a <see cref="System.Net.Http.HttpResponseMessage"/> or <see cref="System.Net.Http.HttpRequestMessage"/> to assign the parsed values to.</param>
+ protected override void ParseStatusLine(string data, HttpResponseMessage message)
+ {
+ if (data == null) throw new ArgumentNullException("data");
+ if (message == null) throw new ArgumentNullException("message");
+
+ var parts = data.Split(' ');
+ if (parts.Length < 2) throw new ArgumentException("data status line is invalid. Insufficient status parts.", "data");
+
+ message.Version = ParseHttpVersion(parts[0].Trim());
+
+ int statusCode = -1;
+ if (!Int32.TryParse(parts[1].Trim(), out statusCode))
+ throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", "data");
+
+ message.StatusCode = (HttpStatusCode)statusCode;
if (parts.Length >= 3)
{
@@ -91,7 +91,6 @@ namespace Rssdp.Infrastructure
}
}
- #endregion
-
- }
-} \ No newline at end of file
+ #endregion
+ }
+}