https.get(url[, options][, callback])
历史
版本 | 变化 |
---|---|
v10.9.0 |
|
v7.5.0 |
|
v0.3.6 | 添加于:v0.3.6 |
参数
url
<string> | <URL>options
<Object> | <string> | <URL> 接受与https.request()
options
,但method
始终设置为GET
。callback
<Function>
与
类似,但用于 HTTPS。http.get()
options
可以是对象、字符串或
对象。如果 URL
options
是一个字符串,它会被自动解析为
。如果是new URL()
对象,会自动转换为普通的URL
options
对象。
const https = require('node:https');
https.get('https://encrypted.google.com/', (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
res.on('data', (d) => {
process.stdout.write(d);
});
}).on('error', (e) => {
console.error(e);
});
相关用法
- Node.js https.request(url[, options][, callback])用法及代码示例
- Node.js https.createServer([options][, requestListener])用法及代码示例
- Node.js https.request()用法及代码示例
- Node.js ServerHttp2Stream http2stream.pushStream(headers[, options], callback)用法及代码示例
- Node.js http.Agent.reuseSocket(socket, request)用法及代码示例
- Node.js http2session.destroyed用法及代码示例
- Node.js http.ServerResponse.setTimeout()用法及代码示例
- Node.js http2.connect(authority[, options][, listener])用法及代码示例
- Node.js http2session.type用法及代码示例
- Node.js http.server.keepAliveTimeout用法及代码示例
- Node.js http.validateHeaderValue(name, value)用法及代码示例
- Node.js http2.bufferSize用法及代码示例
- Node.js http.ClientRequest.maxHeadersCount用法及代码示例
- Node.js http.IncomingMessage.httpVersion用法及代码示例
- Node.js http.IncomingMessage.method用法及代码示例
- Node.js http2session.ping()用法及代码示例
- Node.js http2session.connecting用法及代码示例
- Node.js http.IncomingMessage.aborted用法及代码示例
- Node.js ServerHttp2Stream http2stream.respond([headers[, options]])用法及代码示例
- Node.js http2stream.setTimeout()用法及代码示例
- Node.js http.OutgoingMessage.removeHeader(name)用法及代码示例
- Node.js http.IncomingMessage.complete用法及代码示例
- Node.js http.validateHeaderName()用法及代码示例
- Node.js http.IncomingMessage.rawTrailers用法及代码示例
- Node.js http2session.setTimeout()用法及代码示例
注:本文由纯净天空筛选整理自nodejs.org大神的英文原创作品 https.get(url[, options][, callback])。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。