Skip to content

Commit

Permalink
Merge pull request #207 from AhmedOS/hotfix/large_body_encoding
Browse files Browse the repository at this point in the history
Fix encoding the HTTPBody with SBTRequestPropertyStorage
  • Loading branch information
tcamin authored Mar 26, 2024
2 parents e5c0f7f + e6f8014 commit 7db02d7
Showing 1 changed file with 11 additions and 2 deletions.
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

0 comments on commit 7db02d7

Please sign in to comment.