mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-17 10:58:58 -07:00
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System.Linq;
|
|
using System.Net;
|
|
using System.IO.Compression;
|
|
|
|
namespace MediaBrowser.Controller.Net
|
|
{
|
|
public class RequestContext
|
|
{
|
|
public HttpListenerRequest Request { get; private set; }
|
|
public HttpListenerResponse Response { get; private set; }
|
|
|
|
public RequestContext(HttpListenerContext context)
|
|
{
|
|
Response = context.Response;
|
|
Request = context.Request;
|
|
}
|
|
|
|
public void Respond(Response response)
|
|
{
|
|
Response.AddHeader("Access-Control-Allow-Origin", "*");
|
|
|
|
foreach (var header in response.Headers)
|
|
{
|
|
Response.AddHeader(header.Key, header.Value);
|
|
}
|
|
|
|
Response.ContentType = response.ContentType;
|
|
Response.StatusCode = response.StatusCode;
|
|
|
|
Response.SendChunked = true;
|
|
|
|
GZipStream gzipStream = new GZipStream(Response.OutputStream, CompressionMode.Compress, false);
|
|
|
|
response.WriteStream(Response.OutputStream);
|
|
}
|
|
}
|
|
} |