增加hostname

master
yutent 2023-11-01 14:19:00 +08:00
parent 2203b683f5
commit 9d66a77b4d
2 changed files with 5 additions and 3 deletions

View File

@ -51,6 +51,7 @@ export default class Request {
url = '' url = ''
host = '127.0.0.1' host = '127.0.0.1'
hostname = '127.0.0.1'
protocol = 'http' protocol = 'http'
constructor(req, res, opts = {}) { constructor(req, res, opts = {}) {
@ -60,6 +61,7 @@ export default class Request {
this.#res = res this.#res = res
this.host = req.headers['host'] || '127.0.0.1' this.host = req.headers['host'] || '127.0.0.1'
this.hostname = this.host.split(':')[0]
this.protocol = req.headers['x-forwarded-proto'] || 'http' this.protocol = req.headers['x-forwarded-proto'] || 'http'
this.#cookies = parseCookie(this.headers['cookie'] || '') this.#cookies = parseCookie(this.headers['cookie'] || '')

View File

@ -1,6 +1,6 @@
{ {
"name": "@gm5/request", "name": "@gm5/request",
"version": "2.0.3", "version": "2.0.4",
"description": "对Http的Request进一步封装, 提供常用的API", "description": "对Http的Request进一步封装, 提供常用的API",
"main": "index.js", "main": "index.js",
"author": "yutent", "author": "yutent",
@ -15,8 +15,8 @@
"http" "http"
], ],
"dependencies": { "dependencies": {
"es.shim": "^2.0.1", "es.shim": "^2.2.0",
"iofs": "^1.5.0" "iofs": "^1.5.3"
}, },
"repository": "https://git.wkit.fun/gm5/request.git", "repository": "https://git.wkit.fun/gm5/request.git",
"license": "MIT" "license": "MIT"