dp-s_doc/Object/Http/Http.md

44 lines
1008 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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"
});
});
```
---