Skip to content

how can i use other res as response? #14

Description

@leotian

我想请求一个地址例如
https://xxx.abc.com/ckd/
然后在responseInterceptor把我�透明传输本地的一个响应过来

const mitmproxyConfig = {
  sslConnectInterceptor: (req, cltSocket, head) => {
    console.log('head', head)
    return true
  },
  requestInterceptor: (rOptions, req, res, ssl, next) => {
    console.log(`正在访问:${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}`)
    console.log('cookie:', rOptions.headers.cookie)

    // res.end('Hello node-mitmproxy!')
    next()
  },
  responseInterceptor: (req, res, proxyReq, proxyRes, ssl, next) => {
    req.pipe(request('http://localhost:9850/ckd')).pipe(res)
    next()
  },
}

mitmproxy.createProxy(mitmproxyConfig)

但是这样的话一直报错 uncaughtException: Error: write after end

我怎么能做到这一点呢

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions