Class HttpMessages
- Namespace
- AppleTvControlLibrary.Mrp.AirPlay.Http
- Assembly
- AppleTvControlLibrary.Mrp.dll
Formatting and parsing of the generic HTTP/RTSP request and response messages used by the AirPlay control connection.
public static class HttpMessages
- Inheritance
-
HttpMessages
- Inherited Members
Methods
FormatMessage(string, string, string, string, string?, IReadOnlyDictionary<string, string>?, byte[]?)
Encode an outgoing HTTP/RTSP request message.
public static byte[] FormatMessage(string method, string uri, string protocol = "HTTP/1.1", string userAgent = "AppleTvControlLibrary", string? contentType = null, IReadOnlyDictionary<string, string>? headers = null, byte[]? body = null)
Parameters
methodstringThe request method.
uristringThe request URI/path.
protocolstringThe protocol/version string, e.g. "HTTP/1.1" or "RTSP/1.0".
userAgentstringThe value of the User-Agent header.
contentTypestringAn optional Content-Type header value.
headersIReadOnlyDictionary<string, string>Additional headers to include.
bodybyte[]An optional request body.
Returns
- byte[]
The encoded request bytes.
FormatRequest(HttpRequest)
Encode a HttpRequest back into its wire representation.
public static byte[] FormatRequest(HttpRequest request)
Parameters
requestHttpRequestThe request to encode.
Returns
- byte[]
The encoded request bytes.
FormatResponse(HttpResponse, string)
Encode a HttpResponse into its wire representation.
public static byte[] FormatResponse(HttpResponse response, string serverName = "AppleTvControlLibrary")
Parameters
responseHttpResponseThe response to encode.
serverNamestringThe value used for the Server header when not already present.
Returns
- byte[]
The encoded response bytes.
TryParseRequest(byte[], out HttpRequest?, out byte[])
Parse a buffer that may contain a complete HTTP/RTSP request.
public static bool TryParseRequest(byte[] data, out HttpRequest? request, out byte[] rest)
Parameters
databyte[]The buffer to parse.
requestHttpRequestThe parsed request, if a complete one was found.
restbyte[]The unconsumed remainder of
data.
Returns
TryParseResponse(byte[], out HttpResponse?, out byte[])
Parse a buffer that may contain a complete HTTP/RTSP response.
public static bool TryParseResponse(byte[] data, out HttpResponse? response, out byte[] rest)
Parameters
databyte[]The buffer to parse.
responseHttpResponseThe parsed response, if a complete one was found.
restbyte[]The unconsumed remainder of
data.