MockWebServer class

A mock web server that can be used to test HTTP requests and responses in Dart.

Constructors

MockWebServer()

Properties

hashCode → int
The hash code for this object.
no setterinherited
port → int
The port on which the server is listening.
no setter
requestStream → Stream<Request>
Stream of incoming HTTP request.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
url → String
The URL of the server.
no setter

Methods

dispatchRequest(Request request) → Future<Response>
Dispatch an HTTP request.
enqueue({required int httpCode, required String body, String? contentType}) → void
Adds an HTTP response to the response queue.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shutdown() → Future<void>
Shuts down the server.
start({int? port}) → Future<void>
Starts the server.
takeRequest() → Request
Returns the next HTTP request received by the server.
takeRequestHeaders() → HttpHeaders
Returns the headers of the next HTTP request received by the server.
toString() → String
A string representation of this object.
inherited
verifyNoMoreRequests() → void
Verifies that there are no more incoming HTTP requests.
verifyRequestCount(int count) → void
Verifies that the server has received a certain number of HTTP requests.

Operators

operator ==(Object other) → bool
The equality operator.
inherited