-
-
Notifications
You must be signed in to change notification settings - Fork 386
feat(network-details): Implement header and body extraction #7586
Description
Note
The pull request "feat(network-details): Implement header and body extraction" was created by @43jay but did not reference an issue. Therefore this issue was created for better visibility in external tools like Linear.
📜 Description
Implements extraction of bodies that are JSON, formurlencoded, binary or text.
Relies on knowing the contentType to decide how to interpret the body (NSData ).
Uses text as a fall-back, assumes
💡 Motivation and Context
See first PR in stack.
💚 How did you test it?
Unit tests
xcodebuild test -workspace Sentry.xcworkspace -scheme Sentry -destination 'platform=iOS Simulator,name=iPhone 16 Pro' -only-testing:SentryTests/SentryNetworkBodyTests -only-testing:SentryTests/SentryNetworkRequestDataTests -only-testing:SentryTests/SentryReplayNetworkRequestOrResponseTests | xcbeautify
Test Suite 'SentryNetworkBodyTests' started at 2026-03-04 00:26:36.919.
✔ testInit_withBinaryContentType_shouldCreateArtificialString (0.002 seconds)
✔ testInit_withEmptyData_shouldReturnNil (0.000 seconds)
✔ testInit_withFormURLEncoded_shouldParseAsForm (0.001 seconds)
✔ testInit_withInvalidJSON_shouldFallbackToString (0.000 seconds)
✔ testInit_withJSONArray_shouldParseCorrectly (0.001 seconds)
✔ testInit_withJSONDictionary_shouldParseCorrectly (0.001 seconds)
✔ testInit_withLargeData_shouldTruncate (0.010 seconds)
✔ testInit_withTextData_shouldStoreAsString (0.000 seconds)
✔ testSerialize_withJSONArray_shouldReturnDictionary (0.000 seconds)
✔ testSerialize_withJSONDictionary_shouldReturnDictionary (0.001 seconds)
✔ testSerialize_withNoContentType_shouldDefaultToText (0.000 seconds)
✔ testSerialize_withStringBody_shouldReturnDictionary (0.000 seconds)
Executed 12 tests, with 0 failures (0 unexpected) in 0.018 (0.022) seconds
Test Suite 'SentryNetworkRequestDataTests' started at 2026-03-04 00:26:36.941.
✔ testInit_withMethod_shouldSetMethod (0.000 seconds)
✔ testSerialize_withFullData_shouldReturnCompleteDictionary (0.001 seconds)
✔ testSerialize_withLargeBody_shouldHandleTruncation (0.002 seconds)
✔ testSerialize_withPartialData_shouldOnlyIncludeSetFields (0.000 seconds)
Executed 4 tests, with 0 failures (0 unexpected) in 0.004 (0.005) seconds
Test Suite 'SentryReplayNetworkRequestOrResponseTests' started at 2026-03-04 00:26:36.946.
✔ testExtractHeaders_caseInsensitiveMatching (0.001 seconds)
✔ testExtractHeaders_nonStringValues_convertedToStrings (0.000 seconds)
✔ testExtractHeaders_withNilInputs_returnsEmptyDict (0.000 seconds)
✔ testInit_withAllParameters_shouldSetAllProperties (0.000 seconds)
✔ testSerialize_withAllData_shouldReturnCompleteDict (0.002 seconds)
✔ testSerialize_withNilBody_shouldNotIncludeBody (0.001 seconds)
Executed 6 tests, with 0 failures (0 unexpected) in 0.005 (0.005) seconds
Test Suite 'SentryTests.xctest' passed at 2026-03-04 00:26:36.951.
Executed 22 tests, with 0 failures (0 unexpected) in 0.027 (0.033) seconds
Executed 22 tests, with 0 failures (0 unexpected) in 0.027 (0.034) seconds
📝 Checklist
You have to check all boxes before merging:
- I added tests to verify the changes.
- No new PII added or SDK only sends newly added PII if
sendDefaultPIIis enabled. N/A - I updated the docs if needed. future PR
- I updated the wizard if needed. N/A
- Review from the native team if needed.
- No breaking change or entry added to the changelog. #skip-changelog future PR
- No breaking change for hybrid SDKs or communicated to hybrid SDKs.