diff options
| author | BaronGreenback <jimcartlidge@yahoo.co.uk> | 2020-06-20 19:23:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-20 19:23:56 +0100 |
| commit | b5586e64f5d815f4449930dc53a61a676d0e2df4 (patch) | |
| tree | c82204256da3850fe6bad1e545135caed04d9cf0 /RSSDP/HttpResponseParser.cs | |
| parent | b2e1d7019130f7bf7e74c8af29927226fb30d46c (diff) | |
| parent | bb947718eaee3a8381d9b9e6ed926676de39d7c9 (diff) | |
Merge pull request #25 from jellyfin/master
Update my master
Diffstat (limited to 'RSSDP/HttpResponseParser.cs')
| -rw-r--r-- | RSSDP/HttpResponseParser.cs | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/RSSDP/HttpResponseParser.cs b/RSSDP/HttpResponseParser.cs index b96eaf625..0dd4bb45a 100644 --- a/RSSDP/HttpResponseParser.cs +++ b/RSSDP/HttpResponseParser.cs @@ -10,17 +10,10 @@ namespace Rssdp.Infrastructure /// </summary> public sealed class HttpResponseParser : HttpParserBase<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 + { + "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="HttpResponseMessage"/> instance. @@ -41,16 +34,14 @@ namespace Rssdp.Infrastructure 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> @@ -68,17 +59,29 @@ 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, HttpResponseMessage 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("data status line is invalid. Insufficient status parts.", nameof(data)); + if (parts.Length < 2) + { + throw new ArgumentException("data status line is invalid. Insufficient status parts.", nameof(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.", nameof(data)); + } message.StatusCode = (HttpStatusCode)statusCode; @@ -87,7 +90,5 @@ namespace Rssdp.Infrastructure message.ReasonPhrase = parts[2].Trim(); } } - - #endregion } } |
