Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix encoding the HTTPBody with SBTRequestPropertyStorage #207

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Sources/SBTUITestTunnelCommon/SBTMonitoredNetworkRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))];
Expand Down
Loading