Table of Contents

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

method string

The request method.

uri string

The request URI/path.

protocol string

The protocol/version string, e.g. "HTTP/1.1" or "RTSP/1.0".

userAgent string

The value of the User-Agent header.

contentType string

An optional Content-Type header value.

headers IReadOnlyDictionary<string, string>

Additional headers to include.

body byte[]

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

request HttpRequest

The 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

response HttpResponse

The response to encode.

serverName string

The 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

data byte[]

The buffer to parse.

request HttpRequest

The parsed request, if a complete one was found.

rest byte[]

The unconsumed remainder of data.

Returns

bool

true if a complete request was parsed.

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

data byte[]

The buffer to parse.

response HttpResponse

The parsed response, if a complete one was found.

rest byte[]

The unconsumed remainder of data.

Returns

bool

true if a complete response was parsed.