public sealed class ContentServerServes a content build directory over HTTP, for a developer to point a device at.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The other end of Vixen.Assets' remote content: a content build produces a directory of bundles and a catalog, and this hands them out so a phone can be pointed at a laptop without a CDN in between. It is a development tool and says so — no TLS, no authentication, no caching policy, and it should never be the thing in front of real players.
Byte ranges are the feature. Everything else here is a file copy; ranges are what makes the client's resume work, and a server without them turns every dropped connection on a device into starting the download again. All three forms are answered — bytes=N-, bytes=N-M and the suffix form bytes=-N — because clients in the wild send all three.
A hash file is synthesised when it is not on disk. The update client reads catalog.bin.hash before it reads catalog.bin, and a content build directory copied as-is does not contain one; without this, pointing a device at a build gives a rejected update and no clue why. Computed from the file it names, so it cannot disagree with it.
Nothing outside the root is reachable. The path is percent-decoded first and then parsed as a VirtualPath, which resolves . and .. and refuses anything left climbing above its own root; the result is rebuilt onto the served directory one segment at a time. It is a single gate rather than a check bolted on afterwards, and it is stated that way because a redundant second check reads as defence in depth while actually being unreachable — which is worse than none, since it invites the next reader to believe the first gate is optional.
Fields and properties (2)
public VirtualPath RootThe directory being served.
public int ServedHow many requests have been answered.
Methods (5)
public ContentServer(VirtualFileSystem files, VirtualPath root)Serves a directory.
public ContentReply Serve(string path, string? range = null)Answers one request.
public bool TryResolve(string path, out VirtualPath resolved)Whether a request path names something inside the served directory.
public static bool TryParseRange(string? header, long total, out long offset, out long length)Reads a Range header.
public static string ContentTypeOf(VirtualPath path)What a file is, by extension.
Used by (4)
- ContentServerHostVixen.ContentServer
- ContentServerTestsVixen.ContentServer.Tests
- ServedDirectoryVixen.ContentServer.Tests
- VixenCommandVixen.Cli