Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions 8 src/ModernHttpClient/iOS/NSUrlSessionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,15 @@ ProgressDelegate getAndRemoveCallbackFromRegister(HttpRequestMessage request)
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var headers = request.Headers as IEnumerable<KeyValuePair<string, IEnumerable<string>>>;
var ms = new MemoryStream();
byte[] contentBytes = null;

if (request.Content != null) {
await request.Content.CopyToAsync(ms).ConfigureAwait(false);
contentBytes = await request.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
headers = headers.Union(request.Content.Headers).ToArray();
}

var rq = new NSMutableUrlRequest() {
AllowsCellularAccess = true,
Body = NSData.FromArray(ms.ToArray()),
CachePolicy = NSUrlRequestCachePolicy.UseProtocolCachePolicy,
Headers = headers.Aggregate(new NSMutableDictionary(), (acc, x) => {
acc.Add(new NSString(x.Key), new NSString(String.Join(",", x.Value)));
Expand All @@ -97,6 +96,9 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
HttpMethod = request.Method.ToString().ToUpperInvariant(),
Url = NSUrl.FromString(request.RequestUri.AbsoluteUri),
};
if (contentBytes != null) {
rq.Body = NSData.FromArray(contentBytes);
}

var op = session.CreateDataTask(rq);

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.