- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWebAPI.cs
More file actions
Latest commit
42 lines (36 loc) · 1.37 KB
/
Copy pathWebAPI.cs
File metadata and controls
42 lines (36 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
usingNewtonsoft.Json;
usingSystem;
usingSystem.Collections.Generic;
usingSystem.IO;
usingSystem.Linq;
usingSystem.Net;
usingSystem.Net.Http;
usingSystem.Net.Http.Headers;
usingSystem.Text;
usingSystem.Threading.Tasks;
namespaceHashServer
{
publicclassWebAPI
{
staticreadonlyHttpClientclient;
staticWebAPI()
{
client=newHttpClient();
client.DefaultRequestHeaders.Accept.Add(newMediaTypeWithQualityHeaderValue("application/json"));
client.MaxResponseContentBufferSize=1024*1024;
client.BaseAddress=newUri(Program.Settings.External.gRoot);
}
publicasyncstaticTask<HttpResponseMessage>POST(stringdata,stringuri="https://pdb2json.azurewebsites.net/api/PageHash/x")
{
varresponse=awaitclient.PostAsync(uri,newStringContent(data,Encoding.UTF8,"application/json"));
response.EnsureSuccessStatusCode();
returnresponse;
}
publicasyncstaticTaskProxyObject(stringdata,StreamwriteTo,stringuri="https://pdb2json.azurewebsites.net/api/PageHash/x")
{
varresponse=awaitclient.PostAsync(uri,newStringContent(data,Encoding.UTF8,"application/json"));
response.EnsureSuccessStatusCode();
awaitresponse.Content.CopyToAsync(writeTo);
}
}
}