diff --git a/Sources/SBTUITestTunnelCommon/SBTMonitoredNetworkRequest.m b/Sources/SBTUITestTunnelCommon/SBTMonitoredNetworkRequest.m index 6b161e5..7b90d1b 100644 --- a/Sources/SBTUITestTunnelCommon/SBTMonitoredNetworkRequest.m +++ b/Sources/SBTUITestTunnelCommon/SBTMonitoredNetworkRequest.m @@ -16,6 +16,8 @@ #import "include/SBTMonitoredNetworkRequest.h" #import "include/SBTRequestMatch.h" +#import "include/SBTRequestPropertyStorage.h" +#import "include/SBTUITestTunnel.h" #import "private/NSData+gzip.h" @implementation SBTMonitoredNetworkRequest : NSObject @@ -44,8 +46,15 @@ - (void)encodeWithCoder:(NSCoder *)encoder { [encoder encodeDouble:self.timestamp forKey:NSStringFromSelector(@selector(timestamp))]; [encoder encodeDouble:self.requestTime forKey:NSStringFromSelector(@selector(requestTime))]; - [encoder encodeObject:self.request forKey:NSStringFromSelector(@selector(request))]; - [encoder encodeObject:self.originalRequest forKey:NSStringFromSelector(@selector(originalRequest))]; + + NSMutableURLRequest *fixedRequest = [self.request mutableCopy]; + fixedRequest.HTTPBody = [SBTRequestPropertyStorage propertyForKey:SBTUITunneledNSURLProtocolHTTPBodyKey inRequest:self.request]; + [encoder encodeObject:fixedRequest forKey:NSStringFromSelector(@selector(request))]; + + NSMutableURLRequest *fixedOriginalRequest = [self.originalRequest mutableCopy]; + fixedOriginalRequest.HTTPBody = [SBTRequestPropertyStorage propertyForKey:SBTUITunneledNSURLProtocolHTTPBodyKey inRequest:self.originalRequest]; + [encoder encodeObject:fixedOriginalRequest forKey:NSStringFromSelector(@selector(originalRequest))]; + [encoder encodeObject:self.response forKey:NSStringFromSelector(@selector(response))]; [encoder encodeObject:self.responseData forKey:NSStringFromSelector(@selector(responseData))]; [encoder encodeBool:self.isStubbed forKey:NSStringFromSelector(@selector(isStubbed))];