aboutsummaryrefslogtreecommitdiff
path: root/RSSDP/HttpResponseParser.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2023-11-30 17:40:06 +0100
committerGitHub <noreply@github.com>2023-11-30 17:40:06 +0100
commitcc276838b4edbb67356b805952262c38e9c9cd19 (patch)
tree8cb27ed0ba34fdd2d941f43c09ccc2be70c10abb /RSSDP/HttpResponseParser.cs
parentcf80ea25413b75bbeddaef136fbeee33aa882a60 (diff)
parente46e3be667c76ff9a242d7499aff83d2d10881ed (diff)
Merge pull request #10558 from barronpm/dlna-plugin2
Move DLNA to Plugin (Part 2)
Diffstat (limited to 'RSSDP/HttpResponseParser.cs')
-rw-r--r--RSSDP/HttpResponseParser.cs90
1 files changed, 0 insertions, 90 deletions
diff --git a/RSSDP/HttpResponseParser.cs b/RSSDP/HttpResponseParser.cs
deleted file mode 100644
index c570c84cb..000000000
--- a/RSSDP/HttpResponseParser.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-using System.Net;
-using System.Net.Http;
-using Jellyfin.Extensions;
-
-namespace Rssdp.Infrastructure
-{
- /// <summary>
- /// Parses a string into a <see cref="HttpResponseMessage"/> or throws an exception.
- /// </summary>
- public sealed class HttpResponseParser : HttpParserBase<HttpResponseMessage>
- {
- 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"
- };
-
- /// <summary>
- /// Parses the specified data into a <see cref="HttpResponseMessage"/> instance.
- /// </summary>
- /// <param name="data">A string containing the data to parse.</param>
- /// <returns>A <see cref="HttpResponseMessage"/> instance containing the parsed data.</returns>
- public override HttpResponseMessage Parse(string data)
- {
- HttpResponseMessage retVal = null;
- try
- {
- retVal = new HttpResponseMessage();
-
- Parse(retVal, retVal.Headers, data);
-
- return retVal;
- }
- catch
- {
- retVal?.Dispose();
-
- throw;
- }
- }
-
- /// <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, StringComparison.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="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));
- }
-
- var parts = data.Split(' ');
- if (parts.Length < 2)
- {
- throw new ArgumentException("data status line is invalid. Insufficient status parts.", nameof(data));
- }
-
- message.Version = ParseHttpVersion(parts[0].Trim());
-
- if (!Int32.TryParse(parts[1].Trim(), out var statusCode))
- {
- throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", nameof(data));
- }
-
- message.StatusCode = (HttpStatusCode)statusCode;
-
- if (parts.Length >= 3)
- {
- message.ReasonPhrase = parts[2].Trim();
- }
- }
- }
-}