diff options
| author | telans <telans@protonmail.com> | 2020-06-20 20:35:29 +1200 |
|---|---|---|
| committer | telans <telans@protonmail.com> | 2020-06-20 20:35:29 +1200 |
| commit | 98db8f72e01b608e6c384ecf5b107fc2d105b652 (patch) | |
| tree | 8099ba47507cfa9f1ff9b6e456cf854108298a63 /RSSDP/HttpParserBase.cs | |
| parent | 8e3d8748021fe0336e2fc1211810cc9bbe2c8850 (diff) | |
fix SA1503 for one line if statements
Diffstat (limited to 'RSSDP/HttpParserBase.cs')
| -rw-r--r-- | RSSDP/HttpParserBase.cs | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/RSSDP/HttpParserBase.cs b/RSSDP/HttpParserBase.cs index ff97b6db8..058bfbf55 100644 --- a/RSSDP/HttpParserBase.cs +++ b/RSSDP/HttpParserBase.cs @@ -31,9 +31,20 @@ namespace Rssdp.Infrastructure [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Honestly, it's fine. MemoryStream doesn't mind.")] protected virtual void Parse(T message, System.Net.Http.Headers.HttpHeaders headers, string data) { - if (data == null) throw new ArgumentNullException(nameof(data)); - if (data.Length == 0) throw new ArgumentException("data cannot be an empty string.", nameof(data)); - if (!LineTerminators.Any(data.Contains)) throw new ArgumentException("data is not a valid request, it does not contain any CRLF/LF terminators.", nameof(data)); + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + + if (data.Length == 0) + { + throw new ArgumentException("data cannot be an empty string.", nameof(data)); + } + + if (!LineTerminators.Any(data.Contains)) + { + throw new ArgumentException("data is not a valid request, it does not contain any CRLF/LF terminators.", nameof(data)); + } using (var retVal = new ByteArrayContent(Array.Empty<byte>())) { @@ -66,10 +77,16 @@ namespace Rssdp.Infrastructure /// <returns>A <see cref="Version"/> object containing the parsed version data.</returns> protected Version ParseHttpVersion(string versionData) { - if (versionData == null) throw new ArgumentNullException(nameof(versionData)); + if (versionData == null) + { + throw new ArgumentNullException(nameof(versionData)); + } var versionSeparatorIndex = versionData.IndexOf('/'); - if (versionSeparatorIndex <= 0 || versionSeparatorIndex == versionData.Length) throw new ArgumentException("request header line is invalid. Http Version not supplied or incorrect format.", nameof(versionData)); + if (versionSeparatorIndex <= 0 || versionSeparatorIndex == versionData.Length) + { + throw new ArgumentException("request header line is invalid. Http Version not supplied or incorrect format.", nameof(versionData)); + } return Version.Parse(versionData.Substring(versionSeparatorIndex + 1)); } |
