acceptRequest method

  1. @protected
void acceptRequest(
  1. HttpRequest request,
  2. Encoding encoding
)

Accepts a HTTP request

This method decodes the request with the encoding specified in the content-encoding header, or else the given encoding Then it handles the request using the dispatcher, and responds with the appropriate response

Implementation

@protected
void acceptRequest(HttpRequest request, Encoding encoding) async {
  final httpResponse = request.response;
  if (request.method != 'POST' || !_isRPCPathValid(request)) {
    _report404(httpResponse);
    return;
  }
  try {
    final xmlRpcRequest = await encoding.decodeStream(request);
    final response = await handler.handle(XmlDocument.parse(xmlRpcRequest));
    await _sendResponse(httpResponse, response);
  } on XmlRpcRequestFormatException {
    await _sendResponse(httpResponse,
        handler.handleFault(Fault(-32602, 'invalid method parameters')));
  } on XmlRpcMethodNotFoundException {
    await _sendResponse(httpResponse,
        handler.handleFault(Fault(-32601, 'requested method not found')));
  } on XmlRpcCallException catch (e) {
    await _sendResponse(
        httpResponse,
        handler.handleFault(
            Fault(-32603, 'internal xml-rpc error : ${e.cause}')));
  } on XmlRpcResponseEncodingException {
    await _sendResponse(httpResponse,
        handler.handleFault(Fault(-32603, 'unsupported response')));
  } on Exception catch (e) {
    print('Exception $e');
    rethrow;
  }
}