forward method

  1. @override
Future forward(
  1. String uri, {
  2. HttpRequest? request,
  3. HttpResponse? response,
})
override

Forward this connection to the given uri. *

  • If request and/or response is ignored, the request and/or response
  • of this connection is assumed.
  • If uri is null, connect.uri is assumed, i.e., forwarded to the same handler.
  • After calling this method, the caller shall write the output stream in then, since
  • the request handler for the given URI might handle it asynchronously. For example,
  • await connect.forward(connect, "another");
    
  • connect.response.write("<p>More content</p>");
    
  • ...
    
    • uri - the URI to chain. If omitted, it is the same as this connection.
  • It can contain the query string too.
  • ##Difference between forward and include
  • forward and include are almost the same, except
    • The included request handler won't be able to generate any HTTP headers
  • (it is the job of the caller). Any updates to HTTP headers in the included
  • request handler are simply ignored.
  • Notice the default implementation is connect.forward(connect, uri...).

Implementation

@override
Future forward(String uri, {HttpRequest? request, HttpResponse? response})
=> origin.forward(uri, request: request ?? this.request,
  response: response != null ? response: this.response);