Skip to content

Commit

Permalink
[Network] Resolve Xcode 15 Beta 4 runtime warning (#114)
Browse files Browse the repository at this point in the history
* [Network] Resolve Xcode 15 Beta 4 runtime warning

* Re-work

* Review
  • Loading branch information
ncooke3 authored Jul 18, 2023
1 parent 58d03d2 commit b0c0c65
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion GoogleUtilities/Network/GULNetworkURLSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,15 @@ - (nullable NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request
session = [NSURLSession sessionWithConfiguration:_sessionConfig
delegate:self
delegateQueue:[NSOperationQueue mainQueue]];
postRequestTask = [session uploadTaskWithRequest:request fromData:request.HTTPBody];
// To avoid a runtime warning in Xcode 15 Beta 4, the given `URLRequest`
// should have a nil `HTTPBody`. To workaround this, the given `URLRequest`
// is copied and the `HTTPBody` data is removed.
NSData *givenRequestHTTPBody = [request.HTTPBody copy];
NSMutableURLRequest *requestWithoutHTTPBody = [request mutableCopy];
requestWithoutHTTPBody.HTTPBody = nil;

postRequestTask = [session uploadTaskWithRequest:requestWithoutHTTPBody
fromData:givenRequestHTTPBody];
}

if (!session || !postRequestTask) {
Expand Down

0 comments on commit b0c0c65

Please sign in to comment.