Skip to content

receivedResponse Doesn't Seem to Have Data #860

@agarrharr

Description

@agarrharr

In URLSessionInstrumentationConfiguration() there is a parameter called receivedResponse that takes response, data, and span. It seems like, in my testing, that I don't receive any data when the response includes json data. Am I holding it wrong? Or is the library filtering out some of the responses?

 let networkInstrumentation = URLSessionInstrumentation(
    configuration: URLSessionInstrumentationConfiguration(
        shouldInstrument: { request in
            true
        },
        receivedResponse: { response, dataOrFile, span in
            if let data = dataOrFile as? Data {
                print("Data: ", String(data: data, encoding: .utf8) ?? "binary data")
            } else {
                print("dataOrFile is not data")
            }
        }
    )
)

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions