calcRequestFirstLineLength static method

int calcRequestFirstLineLength(
  1. String method,
  2. String path,
  3. String query
)

Calculation of the first line which appears in a request. This is mainly influenced by the method, path and query of the URL.

Implementation

static int calcRequestFirstLineLength(
  String method,
  String path,
  String query,
) {
  final pathInfo = StringBuffer()..write(path.isEmpty ? '/' : path);

  if (query.isNotEmpty) {
    pathInfo.write('?$query');
  }

  return '$method $pathInfo HTTP/1.1'.length;
}