Commit a42da6c2 authored by 王雪伟's avatar 王雪伟

修改报错

parent a4f3577a
...@@ -88,48 +88,6 @@ public class AdHttpUtil : MonoBehaviour ...@@ -88,48 +88,6 @@ public class AdHttpUtil : MonoBehaviour
} }
} }
//jsonString 为json字符串,post提交的数据包为json
public void _Post<T>(string methodName, Dictionary<string, object> postParas, Action<T> success, Action<string, string> failed)
{
StartCoroutine(PostRequest(BaseGameUrl, methodName, "", postParas, success, failed));
}
private IEnumerator PostRequest<T>(string BaseURL, string methodName, string jsonString, Dictionary<string, object> postParas, Action<T> success, Action<string, string> failed)
{
string url = BaseURL + methodName + "?" + HttpUtil.addParams(postParas);
using (UnityWebRequest webRequest = new UnityWebRequest(url, "POST"))
{
if (jsonString != null && jsonString.Length > 0)
{
byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonString);
webRequest.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
}
webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
foreach (var v in requestHeader)
{
webRequest.SetRequestHeader(v.Key, (string)v.Value);
}
webRequest.timeout = timeOut;
yield return webRequest.SendWebRequest();
if (webRequest.isHttpError || webRequest.isNetworkError)
{
Debug.unityLogger.Log("error:"+webRequest.error + "\n" + webRequest.downloadHandler.text);
if (failed != null)
{
failed(webRequest.error, webRequest.downloadHandler.text);
}
}
else
{
string json = webRequest.downloadHandler.text;
RequestResult("POST RequestUrl=> " + url, json, success, failed);
}
}
}
private void RequestResult<T>(string debugUrl, string json, Action<T> success, Action<string, string> failed) private void RequestResult<T>(string debugUrl, string json, Action<T> success, Action<string, string> failed)
{ {
Debug.unityLogger.Log(HttpLogTag, debugUrl); Debug.unityLogger.Log(HttpLogTag, debugUrl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment