111
This commit is contained in:
@@ -24,12 +24,12 @@ class Http {
|
||||
return encoded;
|
||||
}
|
||||
|
||||
function Request(Type, Url, Content) {
|
||||
function Request(Type, Url, Content, DataType) {
|
||||
local RequestBuffer = Type + " " + Url + " HTTP/1.1\r\nHost: " + Host + "\r\n";
|
||||
|
||||
if (Content) {
|
||||
RequestBuffer += "Content-Length: " + Content.len() + "\r\n";
|
||||
RequestBuffer += "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
RequestBuffer += "Content-Type: " + DataType + "\r\n";
|
||||
RequestBuffer += "\r\n";
|
||||
RequestBuffer += Content;
|
||||
} else {
|
||||
@@ -39,16 +39,19 @@ class Http {
|
||||
}
|
||||
|
||||
// 发送请求
|
||||
function Post(Url, params = null) {
|
||||
function Post(Url, params = null, DataType = "application/x-www-form-urlencoded") {
|
||||
local content = null;
|
||||
if (params != null && typeof params == "table") {
|
||||
content = _EncodeParams(params); // 编码参数
|
||||
}
|
||||
return Request("POST", Url, content);
|
||||
else if (params != null && typeof params == "string") {
|
||||
content = params;
|
||||
}
|
||||
return Request("POST", Url, content, DataType);
|
||||
}
|
||||
|
||||
function Get(Url, Content = null) {
|
||||
return Request("GET", Url, Content);
|
||||
function Get(Url, Content = null, DataType = "application/x-www-form-urlencoded") {
|
||||
return Request("GET", Url, Content, DataType);
|
||||
}
|
||||
|
||||
|
||||
@@ -243,8 +246,7 @@ class HttpResponse {
|
||||
response += "Content-Length: " + JsonString.len() + "\r\n";
|
||||
response += "\r\n";
|
||||
response += JsonString;
|
||||
}
|
||||
else if(typeof Msg == "string") {
|
||||
} else if (typeof Msg == "string") {
|
||||
response += "Content-Type: text/plain\r\n";
|
||||
response += "Content-Length: " + Msg.len() + "\r\n";
|
||||
response += "\r\n";
|
||||
|
||||
Reference in New Issue
Block a user