|
|
@ -3,6 +3,7 @@ using System.Collections.Specialized;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Web;
|
|
|
|
using System.Web;
|
|
|
|
using ServiceStack;
|
|
|
|
using ServiceStack;
|
|
|
|
using ServiceStack.Web;
|
|
|
|
using ServiceStack.Web;
|
|
|
@ -32,19 +33,20 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|
|
|
return header.Substring(ap + 1, end - ap - 1);
|
|
|
|
return header.Substring(ap + 1, end - ap - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LoadMultiPart()
|
|
|
|
async Task LoadMultiPart()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string boundary = GetParameter(ContentType, "; boundary=");
|
|
|
|
string boundary = GetParameter(ContentType, "; boundary=");
|
|
|
|
if (boundary == null)
|
|
|
|
if (boundary == null)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
var input = GetSubStream(InputStream);
|
|
|
|
using (var requestStream = GetSubStream(InputStream))
|
|
|
|
|
|
|
|
{
|
|
|
|
//DB: 30/01/11 - Hack to get around non-seekable stream and received HTTP request
|
|
|
|
//DB: 30/01/11 - Hack to get around non-seekable stream and received HTTP request
|
|
|
|
//Not ending with \r\n?
|
|
|
|
//Not ending with \r\n?
|
|
|
|
var ms = new MemoryStream(32 * 1024);
|
|
|
|
var ms = new MemoryStream(32 * 1024);
|
|
|
|
input.CopyTo(ms);
|
|
|
|
await requestStream.CopyToAsync(ms).ConfigureAwait(false);
|
|
|
|
input = ms;
|
|
|
|
|
|
|
|
|
|
|
|
var input = ms;
|
|
|
|
ms.WriteByte((byte)'\r');
|
|
|
|
ms.WriteByte((byte)'\r');
|
|
|
|
ms.WriteByte((byte)'\n');
|
|
|
|
ms.WriteByte((byte)'\n');
|
|
|
|
|
|
|
|
|
|
|
@ -78,7 +80,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|
|
|
files.AddFile(e.Name, sub);
|
|
|
|
files.AddFile(e.Name, sub);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EndSubStream(input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public NameValueCollection Form
|
|
|
|
public NameValueCollection Form
|
|
|
@ -91,10 +93,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|
|
|
files = new HttpFileCollection();
|
|
|
|
files = new HttpFileCollection();
|
|
|
|
|
|
|
|
|
|
|
|
if (IsContentType("multipart/form-data", true))
|
|
|
|
if (IsContentType("multipart/form-data", true))
|
|
|
|
LoadMultiPart();
|
|
|
|
{
|
|
|
|
else if (
|
|
|
|
var task = LoadMultiPart();
|
|
|
|
IsContentType("application/x-www-form-urlencoded", true))
|
|
|
|
Task.WaitAll(task);
|
|
|
|
LoadWwwForm();
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (IsContentType("application/x-www-form-urlencoded", true))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var task = LoadWwwForm();
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
form.Protect();
|
|
|
|
form.Protect();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -220,15 +227,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|
|
|
return String.Compare(ContentType, ct, true, Helpers.InvariantCulture) == 0;
|
|
|
|
return String.Compare(ContentType, ct, true, Helpers.InvariantCulture) == 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async Task LoadWwwForm()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LoadWwwForm()
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using (Stream input = GetSubStream(InputStream))
|
|
|
|
using (Stream input = GetSubStream(InputStream))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using (StreamReader s = new StreamReader(input, ContentEncoding))
|
|
|
|
using (var ms = new MemoryStream())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await input.CopyToAsync(ms).ConfigureAwait(false);
|
|
|
|
|
|
|
|
ms.Position = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (StreamReader s = new StreamReader(ms, ContentEncoding))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
StringBuilder key = new StringBuilder();
|
|
|
|
StringBuilder key = new StringBuilder();
|
|
|
|
StringBuilder value = new StringBuilder();
|
|
|
|
StringBuilder value = new StringBuilder();
|
|
|
@ -262,8 +270,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (c == -1)
|
|
|
|
if (c == -1)
|
|
|
|
AddRawKeyValue(key, value);
|
|
|
|
AddRawKeyValue(key, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
EndSubStream(input);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|