aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/SocketSharp/RequestMono.cs
diff options
context:
space:
mode:
authorAndrew Rabert <6550543+nvllsvm@users.noreply.github.com>2019-01-22 18:13:47 -0500
committerGitHub <noreply@github.com>2019-01-22 18:13:47 -0500
commit28483bdb54be96ae83e0fded097f534d7e26ba1e (patch)
treee7f4b92326417ebf55eecdf68a01d2c3b9e660d7 /Jellyfin.Server/SocketSharp/RequestMono.cs
parent920c39454c05e979eabe81877269cd4517a03ccf (diff)
parent8106c8393b711a7e1d40487e3caf2b014decbe28 (diff)
Merge pull request #651 from jellyfin/release-10.1.0
Release 10.1.0
Diffstat (limited to 'Jellyfin.Server/SocketSharp/RequestMono.cs')
-rw-r--r--Jellyfin.Server/SocketSharp/RequestMono.cs117
1 files changed, 33 insertions, 84 deletions
diff --git a/Jellyfin.Server/SocketSharp/RequestMono.cs b/Jellyfin.Server/SocketSharp/RequestMono.cs
index 31f289497..45cb323d2 100644
--- a/Jellyfin.Server/SocketSharp/RequestMono.cs
+++ b/Jellyfin.Server/SocketSharp/RequestMono.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -75,7 +75,7 @@ namespace Jellyfin.SocketSharp
//
// We use a substream, as in 2.x we will support large uploads streamed to disk,
//
- HttpPostedFile sub = new HttpPostedFile(e.Filename, e.ContentType, input, e.Start, e.Length);
+ var sub = new HttpPostedFile(e.Filename, e.ContentType, input, e.Start, e.Length);
files[e.Name] = sub;
}
}
@@ -97,12 +97,12 @@ namespace Jellyfin.SocketSharp
}
#if NET_4_0
- if (validateRequestNewMode && !checked_form) {
- // Setting this before calling the validator prevents
- // possible endless recursion
- checked_form = true;
- ValidateNameValueCollection ("Form", query_string_nvc, RequestValidationSource.Form);
- } else
+ if (validateRequestNewMode && !checked_form) {
+ // Setting this before calling the validator prevents
+ // possible endless recursion
+ checked_form = true;
+ ValidateNameValueCollection ("Form", query_string_nvc, RequestValidationSource.Form);
+ } else
#endif
if (validate_form && !checked_form)
{
@@ -113,21 +113,9 @@ namespace Jellyfin.SocketSharp
return form;
}
- public string Accept
- {
- get
- {
- return string.IsNullOrEmpty(request.Headers["Accept"]) ? null : request.Headers["Accept"];
- }
- }
+ public string Accept => string.IsNullOrEmpty(request.Headers["Accept"]) ? null : request.Headers["Accept"];
- public string Authorization
- {
- get
- {
- return string.IsNullOrEmpty(request.Headers["Authorization"]) ? null : request.Headers["Authorization"];
- }
- }
+ public string Authorization => string.IsNullOrEmpty(request.Headers["Authorization"]) ? null : request.Headers["Authorization"];
protected bool validate_cookies, validate_query_string, validate_form;
protected bool checked_cookies, checked_query_string, checked_form;
@@ -138,7 +126,7 @@ namespace Jellyfin.SocketSharp
if (v.Length > 20)
v = v.Substring(0, 16) + "...\"";
- string msg = String.Format("A potentially dangerous Request.{0} value was " +
+ string msg = string.Format("A potentially dangerous Request.{0} value was " +
"detected from the client ({1}={2}).", name, key, v);
throw new Exception(msg);
@@ -160,9 +148,7 @@ namespace Jellyfin.SocketSharp
internal static bool IsInvalidString(string val)
{
- int validationFailureIndex;
-
- return IsInvalidString(val, out validationFailureIndex);
+ return IsInvalidString(val, out var validationFailureIndex);
}
internal static bool IsInvalidString(string val, out int validationFailureIndex)
@@ -219,17 +205,17 @@ namespace Jellyfin.SocketSharp
async Task LoadWwwForm(WebROCollection form)
{
- using (Stream input = InputStream)
+ using (var input = InputStream)
{
using (var ms = new MemoryStream())
{
await input.CopyToAsync(ms).ConfigureAwait(false);
ms.Position = 0;
- using (StreamReader s = new StreamReader(ms, ContentEncoding))
+ using (var s = new StreamReader(ms, ContentEncoding))
{
- StringBuilder key = new StringBuilder();
- StringBuilder value = new StringBuilder();
+ var key = new StringBuilder();
+ var value = new StringBuilder();
int c;
while ((c = s.Read()) != -1)
@@ -281,7 +267,7 @@ namespace Jellyfin.SocketSharp
{
public override string ToString()
{
- StringBuilder result = new StringBuilder();
+ var result = new StringBuilder();
foreach (var pair in this)
{
if (result.Length > 0)
@@ -328,13 +314,13 @@ namespace Jellyfin.SocketSharp
public override int Read(byte[] buffer, int dest_offset, int count)
{
if (buffer == null)
- throw new ArgumentNullException("buffer");
+ throw new ArgumentNullException(nameof(buffer));
if (dest_offset < 0)
- throw new ArgumentOutOfRangeException("dest_offset", "< 0");
+ throw new ArgumentOutOfRangeException(nameof(dest_offset), "< 0");
if (count < 0)
- throw new ArgumentOutOfRangeException("count", "< 0");
+ throw new ArgumentOutOfRangeException(nameof(count), "< 0");
int len = buffer.Length;
if (dest_offset > len)
@@ -410,30 +396,17 @@ namespace Jellyfin.SocketSharp
throw new NotSupportedException();
}
- public override bool CanRead
- {
- get { return true; }
- }
- public override bool CanSeek
- {
- get { return true; }
- }
- public override bool CanWrite
- {
- get { return false; }
- }
+ public override bool CanRead => true;
- public override long Length
- {
- get { return end - offset; }
- }
+ public override bool CanSeek => true;
+
+ public override bool CanWrite => false;
+
+ public override long Length => end - offset;
public override long Position
{
- get
- {
- return position - offset;
- }
+ get => position - offset;
set
{
if (value > Length)
@@ -451,37 +424,13 @@ namespace Jellyfin.SocketSharp
this.stream = new ReadSubStream(base_stream, offset, length);
}
- public string ContentType
- {
- get
- {
- return content_type;
- }
- }
+ public string ContentType => content_type;
- public int ContentLength
- {
- get
- {
- return (int)stream.Length;
- }
- }
+ public int ContentLength => (int)stream.Length;
- public string FileName
- {
- get
- {
- return name;
- }
- }
+ public string FileName => name;
- public Stream InputStream
- {
- get
- {
- return stream;
- }
- }
+ public Stream InputStream => stream;
}
class Helpers
@@ -546,7 +495,7 @@ namespace Jellyfin.SocketSharp
const byte HYPHEN = (byte)'-', LF = (byte)'\n', CR = (byte)'\r';
- // See RFC 2046
+ // See RFC 2046
// In the case of multipart entities, in which one or more different
// sets of data are combined in a single body, a "multipart" media type
// field must appear in the entity's header. The body must then contain
@@ -764,7 +713,7 @@ namespace Jellyfin.SocketSharp
if (at_eof || ReadBoundary())
return null;
- Element elem = new Element();
+ var elem = new Element();
string header;
while ((header = ReadHeaders()) != null)
{