📜 Description
SentryNetworkBody
Extract request/response bodies that are either JSON, formurlencoded, binary or text.
- Relies on knowing the contentType to decide how to interpret the body (
NSData ).
- Defaults to interpreting body as text: tries
NSUTF8StringEncoding , then NSISOLatin1StringEncoding then gives up with a BODY_PARSE_ERROR warning.
SentryReplayNetworkRequestOrResponse
- case-insensitive header extraction
💡 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:
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
SentryNetworkBodyExtract request/response bodies that are either JSON, formurlencoded, binary or text.
NSData).NSUTF8StringEncoding, thenNSISOLatin1StringEncodingthen gives up with aBODY_PARSE_ERRORwarning.SentryReplayNetworkRequestOrResponse💡 Motivation and Context
See first PR in stack.
💚 How did you test it?
Unit tests
📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled. N/A