Skip to content

Commit bf35643

Browse files
committed
fix error
1 parent 79e694f commit bf35643

3 files changed

Lines changed: 41 additions & 37 deletions

File tree

Assets/CustomUnity/ExtensionMethods/UnityWebRequestExtension.cs

Lines changed: 0 additions & 37 deletions
This file was deleted.

Assets/CustomUnity/WebRequest.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using UnityEngine.Networking;
2+
3+
namespace CustomUnity
4+
{
5+
public static class WebRequest
6+
{
7+
public static UnityWebRequest PostJson(string uri, string json)
8+
{
9+
var ret = UnityWebRequest.Post(uri, json);
10+
ret.uploadHandler.contentType = "application/json";
11+
return ret;
12+
}
13+
14+
public static UnityWebRequest PutJson(string uri, string json)
15+
{
16+
var ret = UnityWebRequest.Put(uri, json);
17+
ret.uploadHandler.contentType = "application/json";
18+
return ret;
19+
}
20+
21+
public static UnityWebRequest Post(string uri, byte[] payload, string contentType)
22+
{
23+
return new UnityWebRequest(
24+
uri,
25+
UnityWebRequest.kHttpVerbPOST,
26+
new DownloadHandlerBuffer(),
27+
new UploadHandlerRaw(payload) { contentType = contentType }
28+
);
29+
}
30+
31+
public static UnityWebRequest Put(string uri, byte[] payload, string contentType)
32+
{
33+
return new UnityWebRequest(
34+
uri,
35+
UnityWebRequest.kHttpVerbPOST,
36+
new DownloadHandlerBuffer(),
37+
new UploadHandlerRaw(payload) { contentType = contentType }
38+
);
39+
}
40+
}
41+
}

Assets/CustomUnity/ExtensionMethods/UnityWebRequestExtension.cs.meta renamed to Assets/CustomUnity/WebRequest.cs.meta

File renamed without changes.

0 commit comments

Comments
 (0)