A server-side object that contains the content of and information about an HTTP request.
Note: Check out the http_server package, which makes working with the low-level dart:io HTTP server subsystem easier.
HttpRequest objects are generated by an HttpServer,
which listens for HTTP requests on a specific host and port.
For each request received, the HttpServer, which is a Stream,
generates an HttpRequest object and adds it to the stream.
An HttpRequest object delivers the body content of the request
as a stream of byte lists.
The object also contains information about the request,
such as the method, URI, and headers.
In the following code, an HttpServer listens
for HTTP requests. When the server receives a request,
it uses the HttpRequest object's method property to dispatch requests.
final HOST = InternetAddress.loopbackIPv4;
final PORT = 80;
HttpServer.bind(HOST, PORT).then((_server) {
_server.listen((HttpRequest request) {
switch (request.method) {
case 'GET':
handleGetRequest(request);
break;
case 'POST':
...
}
},
onError: handleError); // listen() failed.
}).catchError(handleError);
An HttpRequest object provides access to the associated HttpResponse object through the response property. The server writes its response to the body of the HttpResponse object. For example, here's a function that responds to a request:
void handleGetRequest(HttpRequest req) {
HttpResponse res = req.response;
res.write('Received request ${req.method}: ${req.uri.path}');
res.close();
}
test accepts any element provided by this stream. [...]
Stream<R>. [...]
needle occurs in the elements provided by this stream. [...]
indexth data event of this stream. [...]
test accepts all elements provided by this stream. [...]
test. [...]
combine. [...]
action on each element of this stream. [...]
test. [...]
streamConsumer. [...]
combine. [...]
test. [...]
count data events from this stream. [...]
test. [...]
count data events of this stream. [...]
test is successful. [...]
streamTransformer to this stream. [...]