const iconv = require('iconv-lite');
const scripts = require('./scripts');
const util = require('./util');

const getHandlerName = (name) => {
  return `handle${name[0].toUpperCase()}${name.substring(1)}`;
};

module.exports = (name) => {
  const eventName = name[0] === 'r' ? 'request' : 'connect';
  return (server, options) => {
    options = Object.assign({
      getCharset: util.getCharset,
      isText: util.isText,
      iconv,
    }, options);
    server.on(eventName, async (req, res) => {
      const handleRequest = scripts.getHandler({ req })[getHandlerName(name)];
      if (!util.isFunction(handleRequest)) {
        return req.pipe(res);
      }
      try {
        await handleRequest(req, res, options);
      } catch (err) {}
    });
  };
};

@@ -490,24 +490,117 @@
 , res) =%3E %7B%0A
+      const oReq = req.originalReq;%0A      oReq.ruleValue = oReq.ruleValue %7C%7C oReq.pipeValue;%0A
       const 

支持 pipeValue