Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MultipartFormDataContent.cs
Go to the documentation of this file.
1using System.IO;
5
6namespace System.Net.Http;
7
9{
11 : base("form-data")
12 {
13 }
14
15 public MultipartFormDataContent(string boundary)
16 : base("form-data", boundary)
17 {
18 }
19
20 public override void Add(HttpContent content)
21 {
22 if (content == null)
23 {
24 throw new ArgumentNullException("content");
25 }
26 if (content.Headers.ContentDisposition == null)
27 {
28 content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
29 }
30 base.Add(content);
31 }
32
33 public void Add(HttpContent content, string name)
34 {
35 if (content == null)
36 {
37 throw new ArgumentNullException("content");
38 }
39 if (string.IsNullOrWhiteSpace(name))
40 {
42 }
43 AddInternal(content, name, null);
44 }
45
46 public void Add(HttpContent content, string name, string fileName)
47 {
48 if (content == null)
49 {
50 throw new ArgumentNullException("content");
51 }
52 if (string.IsNullOrWhiteSpace(name))
53 {
55 }
56 if (string.IsNullOrWhiteSpace(fileName))
57 {
59 }
60 AddInternal(content, name, fileName);
61 }
62
63 private void AddInternal(HttpContent content, string name, string fileName)
64 {
65 if (content.Headers.ContentDisposition == null)
66 {
67 ContentDispositionHeaderValue contentDispositionHeaderValue = new ContentDispositionHeaderValue("form-data");
68 contentDispositionHeaderValue.Name = name;
69 contentDispositionHeaderValue.FileName = fileName;
70 contentDispositionHeaderValue.FileNameStar = fileName;
71 content.Headers.ContentDisposition = contentDispositionHeaderValue;
72 }
73 base.Add(content);
74 }
75
77 {
78 if (!(GetType() == typeof(MultipartFormDataContent)))
79 {
80 return base.SerializeToStreamAsync(stream, context, cancellationToken);
81 }
83 }
84}
ContentDispositionHeaderValue? ContentDisposition
HttpContentHeaders Headers
async Task SerializeToStreamAsyncCore(Stream stream, TransportContext context, CancellationToken cancellationToken)
void AddInternal(HttpContent content, string name, string fileName)
void Add(HttpContent content, string name, string fileName)
override Task SerializeToStreamAsync(Stream stream, TransportContext? context, CancellationToken cancellationToken)
void Add(HttpContent content, string name)
static string net_http_argument_empty_string
Definition SR.cs:52
Definition SR.cs:7