request.url
添加于:v8.4.0
请求 URL 字符串。这仅包含实际 HTTP 请求中存在的 URL。如果请求是:
GET /status?name=ryan HTTP/1.1
Accept: text/plain
那么 request.url
将是:
'/status?name=ryan'
要将 url 解析为各个部分,可以使用new URL()
:
$ node
> new URL('/status?name=ryan', 'http://example.com')
URL {
href: 'http://example.com/status?name=ryan',
origin: 'http://example.com',
protocol: 'http:',
username: '',
password: '',
host: 'example.com',
hostname: 'example.com',
port: '',
pathname: '/status',
search: '?name=ryan',
searchParams: URLSearchParams { 'name' => 'ryan' },
hash: ''
}
相关用法
- Node.js request.socket用法及代码示例
- Node.js http.ClientRequest request.getHeaders()用法及代码示例
- Node.js http2.Http2ServerRequest request.headers用法及代码示例
- Node.js http.ClientRequest request.setHeader(name, value)用法及代码示例
- Node.js request.writableEnded用法及代码示例
- Node.js http.ClientRequest request.getHeaderNames()用法及代码示例
- Node.js http.ClientRequest request.removeHeader(name)用法及代码示例
- Node.js http.ClientRequest request.getHeader(name)用法及代码示例
- Node.js http.ClientRequest request.reusedSocket用法及代码示例
- Node.js http2.Http2ServerRequest request.rawHeaders用法及代码示例
- Node.js http.ClientRequest request.hasHeader(name)用法及代码示例
- Node.js http.ClientRequest request.getRawHeaderNames()用法及代码示例
- Node.js http.ClientRequest request.socket用法及代码示例
- Node.js require.cache用法及代码示例
- Node.js require.main用法及代码示例
- Node.js require.extensions用法及代码示例
- Node.js require(id)用法及代码示例
- Node.js http.ServerResponse response.statusCode用法及代码示例
- Node.js readStream.isRaw用法及代码示例
- Node.js response.writeContinue()用法及代码示例
- Node.js http2.Http2ServerResponse response.removeHeader(name)用法及代码示例
- Node.js response.removeHeader()用法及代码示例
- Node.js http.ServerResponse response.getHeaderNames()用法及代码示例
- Node.js http2.Http2ServerResponse response.hasHeader(name)用法及代码示例
- Node.js http.ServerResponse response.removeHeader(name)用法及代码示例
注:本文由纯净天空筛选整理自nodejs.org大神的英文原创作品 request.url。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。