Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ UploadStringAsync() [3/3]

void System.Net.WebClient.UploadStringAsync ( Uri address,
string? method,
string data,
object? userToken )
inline

Definition at line 1630 of file WebClient.cs.

1631 {
1632 ArgumentNullException.ThrowIfNull(address, "address");
1633 ArgumentNullException.ThrowIfNull(data, "data");
1634 if (method == null)
1635 {
1636 method = MapToDefaultMethod(address);
1637 }
1638 AsyncOperation asyncOperation = StartAsyncOperation(userToken);
1639 try
1640 {
1641 byte[] bytes = Encoding.GetBytes(data);
1642 _method = method;
1643 _contentLength = bytes.Length;
1644 UploadBitsAsync(_webRequest = GetWebRequest(GetUri(address)), null, bytes, 0, null, null, asyncOperation, delegate(byte[] bytesResult, Exception error, AsyncOperation uploadAsyncOp)
1645 {
1646 string result = null;
1647 if (error == null && bytesResult != null)
1648 {
1649 try
1650 {
1651 result = GetStringUsingEncoding(_webRequest, bytesResult);
1652 }
1653 catch (Exception ex2) when (!(ex2 is OutOfMemoryException))
1654 {
1655 error = GetExceptionToPropagate(ex2);
1656 }
1657 }
1658 InvokeOperationCompleted(uploadAsyncOp, _uploadStringOperationCompleted, new UploadStringCompletedEventArgs(result, error, _canceled, uploadAsyncOp.UserSuppliedState));
1659 });
1660 }
1661 catch (Exception ex) when (!(ex is OutOfMemoryException))
1662 {
1663 UploadStringCompletedEventArgs eventArgs = new UploadStringCompletedEventArgs(null, GetExceptionToPropagate(ex), _canceled, asyncOperation.UserSuppliedState);
1665 }
1666 }
Uri GetUri(string address)
Definition WebClient.cs:990
virtual WebRequest GetWebRequest(Uri address)
Definition WebClient.cs:428
WebRequest _webRequest
Definition WebClient.cs:76
static Exception GetExceptionToPropagate(Exception e)
string GetStringUsingEncoding(WebRequest request, byte[] data)
AsyncOperation StartAsyncOperation(object userToken)
Definition WebClient.cs:366
string MapToDefaultMethod(Uri address)
SendOrPostCallback _uploadStringOperationCompleted
Definition WebClient.cs:108
void InvokeOperationCompleted(AsyncOperation asyncOp, SendOrPostCallback callback, AsyncCompletedEventArgs eventArgs)
async void UploadBitsAsync(WebRequest request, Stream readStream, byte[] buffer, int chunkSize, byte[] header, byte[] footer, AsyncOperation asyncOp, Action< byte[], Exception, AsyncOperation > completionDelegate)
virtual byte[] GetBytes(char[] chars)
Definition Encoding.cs:781

References System.Net.WebClient._canceled, System.Net.WebClient._contentLength, System.Net.WebClient._method, System.Net.WebClient._uploadStringOperationCompleted, System.Net.WebClient._webRequest, System.bytes, System.Text.Encoding.GetBytes(), System.Net.WebClient.GetExceptionToPropagate(), System.Net.WebClient.GetStringUsingEncoding(), System.Net.WebClient.GetUri(), System.Net.WebClient.GetWebRequest(), System.Net.WebClient.InvokeOperationCompleted(), System.Net.WebClient.MapToDefaultMethod(), System.Net.WebClient.StartAsyncOperation(), System.ArgumentNullException.ThrowIfNull(), System.Net.WebClient.UploadBitsAsync(), and System.ComponentModel.AsyncOperation.UserSuppliedState.