Skip to content

Commit

Permalink
Merge pull request #9 from DataDog/CIAPP-570-Adjust-network-instrumen…
Browse files Browse the repository at this point in the history
…tation-for-dd-sdk-usage

CIAPP-570 - Adjust network instrumentation for dd-sdk usage 

Don't convert requests made with URL internally to requests using URLRequest if we are not injecting headers.
  • Loading branch information
Ignacio Bonafonte authored Nov 19, 2020
2 parents 9f46c59 + 4bf3628 commit c0acac8
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 c0acac8

Please sign in to comment.