Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FormUrlEncodedContent.cs
Go to the documentation of this file.
2using System.IO;
4using System.Text;
7
8namespace System.Net.Http;
9
11{
14 {
15 base.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
16 }
17
19 {
20 if (nameValueCollection == null)
21 {
22 throw new ArgumentNullException("nameValueCollection");
23 }
26 {
27 if (stringBuilder.Length > 0)
28 {
29 stringBuilder.Append('&');
30 }
31 stringBuilder.Append(Encode(item.Key));
32 stringBuilder.Append('=');
33 stringBuilder.Append(Encode(item.Value));
34 }
35 return HttpRuleParser.DefaultHttpEncoding.GetBytes(stringBuilder.ToString());
36 }
37
38 private static string Encode(string data)
39 {
40 if (string.IsNullOrEmpty(data))
41 {
42 return string.Empty;
43 }
44 return Uri.EscapeDataString(data).Replace("%20", "+");
45 }
46
48 {
49 if (!(GetType() == typeof(FormUrlEncodedContent)))
50 {
51 return base.SerializeToStreamAsync(stream, context, cancellationToken);
52 }
54 }
55
57 {
58 if (!(GetType() == typeof(FormUrlEncodedContent)))
59 {
60 return null;
61 }
63 }
64}
Task SerializeToStreamAsyncCore(Stream stream, CancellationToken cancellationToken)
FormUrlEncodedContent(IEnumerable< KeyValuePair< string, string > > nameValueCollection)
override Task SerializeToStreamAsync(Stream stream, TransportContext? context, CancellationToken cancellationToken)
static byte[] GetContentByteArray(IEnumerable< KeyValuePair< string, string > > nameValueCollection)
static Encoding DefaultHttpEncoding
static string EscapeDataString(string stringToEscape)
Definition Uri.cs:4087