1111
This commit is contained in:
44
Object/Http/Http.md
Normal file
44
Object/Http/Http.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Http 类函数文档
|
||||
|
||||
**类说明**:
|
||||
`Http`类为Http请求相关操作(注意将会阻塞线程)。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**懒得写文档 直接放出使用说明**:
|
||||
|
||||
---
|
||||
|
||||
```
|
||||
//公有方法 获取本机IP
|
||||
local MyIp = Http.GetMyIp();
|
||||
print(MyIp);
|
||||
|
||||
//私有方法 发送Get请求
|
||||
local SO = Http("www.baidu.com");
|
||||
local BaiduBody = SO.Get("/");
|
||||
print(BaiduBody);
|
||||
|
||||
//私有方法 发送带参数的Post请求
|
||||
local SO = Http("192.168.200.189","1311");
|
||||
local Res = SO.Post("/",{username = "lenheart", password = "123456"});
|
||||
|
||||
//创建一个Http Server
|
||||
local HS = HttpServer("0.0.0.0","41817");
|
||||
HS.Listen(function (SocketObject,Msg)
|
||||
{
|
||||
print("收到请求内容: " + Msg);
|
||||
|
||||
//回复字符串
|
||||
//SocketObject.Write("hello world");
|
||||
//回复Json 直接Write Table就是Json
|
||||
SocketObject.Write({
|
||||
user = "lenheart",
|
||||
msg = "hello world"
|
||||
});
|
||||
});
|
||||
|
||||
```
|
||||
---
|
||||
Reference in New Issue
Block a user