1 Star 0 Fork 0

speedphp/phpx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test.js 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
jake 提交于 2017-11-24 10:56 . commit 0.0.2 for proxy ok
'use strict'
const http = require('http')
const request = require('request')
const assert = require('assert')
const phpx = require('./phpx.js')
describe('Test', () => {
let backend, proxy
before(done => {
backend = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.write('hello world')
res.end()
}).listen(9000)
proxy = phpx('http://127.0.0.1:9000').listen(8000)
done()
})
it('Go throught to the direct server', done => {
request('http://127.0.0.1:9000', (error, response, body) => {
assert.equal(response.statusCode, 200)
assert.equal(body, 'hello world')
done()
})
})
it('Go by proxy and record', done => {
request('http://127.0.0.1:8000', (error, response, body) => {
assert.equal(response.statusCode, 200)
assert.equal(body, 'hello world')
done()
})
})
after(done => {
backend.close()
proxy.close()
done()
})
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/SpeedPHP/phpx.git
git@gitee.com:SpeedPHP/phpx.git
SpeedPHP
phpx
phpx
master

搜索帮助