Class HttpHelper
- Namespace
 - Alis.Core.Network
 
- Assembly
 - Alis.dll
 
The http helper class
public class HttpHelperInheritance
Inherited Members
Fields
HttpGetHeaderRegex
The http get header regex
private const string HttpGetHeaderRegex = "^GET(.*)HTTP\\/1\\.1"Field Value
Methods
CalculateWebSocketKey()
Calculates a random WebSocket key that can be used to initiate a WebSocket handshake
public static string CalculateWebSocketKey()Returns
- string
 - 
A random websocket key
 
ComputeSocketAcceptString(string) Deprecated
Obsolete
Computes a WebSocket accept string from a given key
[Obsolete("Obsolete")]
public static string ComputeSocketAcceptString(string secWebSocketKey)Parameters
secWebSocketKeystring- 
The web socket key to base the accept string on
 
Returns
- string
 - 
A web socket accept string
 
GetPathFromHeader(string)
Gets the path from the HTTP header
public static string GetPathFromHeader(string httpHeader)Parameters
httpHeaderstring- 
The HTTP header to read
 
Returns
- string
 - 
The path
 
GetSubProtocols(string)
Gets the sub protocols using the specified http header
public static IList<string> GetSubProtocols(string httpHeader)Parameters
httpHeaderstring- 
The http header
 
Returns
Exceptions
- EntityTooLargeException
 - 
Sec-WebSocket-Protocol exceeded the maximum of length of {MAX_LEN}
 
IsWebSocketUpgradeRequest(string)
Decodes the header to detect is this is a web socket upgrade response
public static bool IsWebSocketUpgradeRequest(string header)Parameters
headerstring- 
The HTTP header
 
Returns
- bool
 - 
True if this is an http WebSocket upgrade response
 
ReadHttpHeaderAsync(Stream, CancellationToken)
Reads an http header as per the HTTP spec
public static Task<string> ReadHttpHeaderAsync(Stream stream, CancellationToken token)Parameters
streamStream- 
The stream to read UTF8 text from
 tokenCancellationToken- 
The cancellation token
 
Returns
ReadHttpResponseCode(string)
Reads the HTTP response code from the http response string
public static string ReadHttpResponseCode(string response)Parameters
responsestring- 
The response string
 
Returns
- string
 - 
the response code
 
WriteHttpHeaderAsync(string, Stream, CancellationToken)
Writes an HTTP response string to the stream
public static Task WriteHttpHeaderAsync(string response, Stream stream, CancellationToken token)Parameters
responsestring- 
The response (without the new line characters)
 streamStream- 
The stream to write to
 tokenCancellationToken- 
The cancellation token