Class MicroServer
Provides a minimalistic HTTP web server that can provide only a single file. Useful for testing download code.
Namespace: NanoByte.Common.Net
Assembly: NanoByte.Common.dll
Syntax
public sealed class MicroServer : Object
Constructors
MicroServer(String, Stream)
Starts a HTTP web server that listens on a random port.
Declaration
public MicroServer(string resourceName, Stream fileContent)
Parameters
Type | Name | Description |
---|---|---|
String | resourceName | The HTTP resource name under which to provide the content. |
Stream | fileContent | The content of the file to serve. |
Properties
FileContent
The content of the file to be served under FileUri.
Declaration
public Stream FileContent { get; }
Property Value
Type | Description |
---|---|
Stream |
FileUri
The complete URL under which the server provides its file.
Declaration
public Uri FileUri { get; }
Property Value
Type | Description |
---|---|
Uri |
ServerUri
The URL under which the server root can be reached. Usually you should use FileUri instead.
Declaration
public Uri ServerUri { get; }
Property Value
Type | Description |
---|---|
Uri |
Slow
Wait for twenty seconds every time before finishing a response.
Declaration
public bool Slow { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
Dispose()
Stops listening for incoming HTTP connections.
Declaration
public void Dispose()