Ai
1 Star 1 Fork 1

草鞋没号/test-http-proxy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
express.ts 906 Bytes
一键复制 编辑 原始数据 按行查看 历史
草鞋没号 提交于 2020-12-08 15:39 +08:00 . first commit
import express from 'express'
import { get } from 'https'
const app = express()
const location = {
hash: "",
host: "www.jianshu.com",
hostname: "www.jianshu.com",
href: "https://www.jianshu.com/",
origin: "https://www.jianshu.com",
pathname: "/",
port: "",
protocol: "https:",
}
app.get('/', async (req, res, next) => {
const handle = get(location.origin, response => {
if (response.statusCode !== 200) {
console.log('statusCode:', response.statusCode)
return
}
const data = []
response.setEncoding('utf-8')
response.on('data', chunk => {
data.push(chunk)
})
response.on('end', () => {
const result = Buffer.concat(data).toString()
console.log('result:\n', result)
})
})
handle.on('error', err => {
console.log('Error:\n ', err)
})
next()
})
app.listen(3000, () => { console.log(`Server run at 3000 port.`) })
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cxmh/test-http-proxy.git
git@gitee.com:cxmh/test-http-proxy.git
cxmh
test-http-proxy
test-http-proxy
master

搜索帮助