node.js——http模块
来源:互联网 发布:网络机柜走线视频教程 编辑:程序博客网 时间:2024/05/16 00:39
要使用 HTTP 服务器与客户端,需要 require('http')
。
http.Agent 类
Agent
负责为 HTTP 客户端管理连接的持续与复用const http = require('http')querystring = require('querystring');const params = { test: '111111'}const userInfo = { params: JSON.stringify(params)}const options = { hostname: '127.0.0.1', port: 80, path: '/url', method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': Buffer.byteLength(querystring.stringify(userInfo)) }};const req = http.request(options, (res) => { res.setEncoding('utf8'); console.log('状态码:', res.statusCode); console.log('请求头:', res.headers); res.on('data', (d) => { process.stdout.write(d); });});req.write(querystring.stringify(userInfo));req.on('error', (e) => { console.error(e);});req.end();
阅读全文
0 0
- node.js——http模块
- Node.js——http && fs模块
- Node.js HTTP模块
- Node.js —— 使用http模块创建Web服务器
- Node.js 的 http 模块
- Node.js中的HTTP模块
- node.js的http模块
- Node.js基本模块http
- Node.js—Node模块机制
- Node.js HTTP模块与事件模块
- node.js fs,http 模块用法
- Node.js http模块 设置响应头
- node.js之基本http处理模块
- Node.js核心模块http客户端
- Node.js学习之内置模块http
- node.js模块学习(三) http
- Node.js——fs模块
- Node.js——npm模块
- caffe安装
- webrtc 建立连接流程
- django报错: NoReverseMatch at / 'devops' is not a registered namespace
- SpringCloud(第 003 篇)服务发现服务端EurekaServer微服务
- spring-cloud-eureka-server之spring-cloud-1.3.4(Dalston.SR3)-boot(1.5.6) 学习笔记
- node.js——http模块
- MySQL-5.7.18绿色版安装和配置
- 使用字符串输入流从字符串中提取数据
- Linux AppImage应用软件的用法(文末追加Linux游戏站)
- kettle介绍
- 2017西安网络赛C_SUM
- 线程与多线程
- 关于C-COT的一些想法 by小白
- ios-VFL语言