Got at least one data fetching method working; turns out, we can't use a patched LogicStack to get the data

This commit is contained in:
2026-01-14 22:11:11 +01:00
parent 40a8431464
commit 3f7122d30a
350 changed files with 41444 additions and 119 deletions

View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Specialized;
using System.Globalization;
using System.Net;
using System.Text;
namespace EmbedIO.Net.Internal
{
internal class WebSocketHandshakeResponse
{
private const int HandshakeStatusCode = (int)HttpStatusCode.SwitchingProtocols;
internal WebSocketHandshakeResponse(IHttpContext context)
{
ProtocolVersion = HttpVersion.Version11;
Headers = context.Response.Headers;
Headers.Clear(); // Use only headers mentioned in RFC6455 - scrap all the rest.
StatusCode = HandshakeStatusCode;
Reason = HttpListenerResponseHelper.GetStatusDescription(HandshakeStatusCode);
Headers[HttpHeaderNames.Upgrade] = "websocket";
Headers[HttpHeaderNames.Connection] = "Upgrade";
foreach (var cookie in context.Request.Cookies)
{
Headers.Add("Set-Cookie", cookie.ToString());
}
}
public string Reason { get; }
public int StatusCode { get; }
public NameValueCollection Headers { get; }
public Version ProtocolVersion { get; }
public override string ToString()
{
var output = new StringBuilder(64)
.AppendFormat(CultureInfo.InvariantCulture, "HTTP/{0} {1} {2}\r\n", ProtocolVersion, StatusCode, Reason);
foreach (var key in Headers.AllKeys)
{
_ = output.AppendFormat(CultureInfo.InvariantCulture, "{0}: {1}\r\n", key, Headers[key]);
}
_ = output.Append("\r\n");
return output.ToString();
}
}
}