Skip to content

Commit

Permalink
CIAPP-570 - Adjust network instrumentation for dd-sdk usage
Browse files Browse the repository at this point in the history
Don't convert requests made with URL to URLRequest if we are not injecting headers, since it is not needed
  • Loading branch information
Ignacio Bonafonte committed Nov 19, 2020
1 parent 9f46c59 commit 4bf3628
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class DDNetworkInstrumentation {
let sessionTaskId = UUID().uuidString

let block: @convention(block) (URLSession, AnyObject) -> URLSessionTask = { session, argument in
if let url = argument as? URL {
if let url = argument as? URL,
self.injectHeaders == true {
let request = URLRequest(url: url)
if selector == #selector(URLSession.dataTask(with:) as (URLSession) -> (URL) -> URLSessionDataTask) {
return session.dataTask(with: request)
Expand Down Expand Up @@ -179,7 +180,8 @@ class DDNetworkInstrumentation {
let sessionTaskId = UUID().uuidString

let block: @convention(block) (URLSession, AnyObject, @escaping (Any?, URLResponse?, Error?) -> Void) -> URLSessionTask = { session, argument, completion in
if let url = argument as? URL {
if let url = argument as? URL,
self.injectHeaders == true {
let request = URLRequest(url: url)

if selector == #selector(URLSession.dataTask(with:completionHandler:) as (URLSession) -> (URL, @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask) {
Expand Down

0 comments on commit 4bf3628

Please sign in to comment.