Skip to content

Commit 218a897

Browse files
committed
Fix issue with OHHTTPStubsResponse+JSON when nil headers dictionary
1 parent 2906c3a commit 218a897

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

OHHTTPStubs.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "OHHTTPStubs"
4-
s.version = "2.3.0"
4+
s.version = "2.3.1"
55

66
s.summary = "Stubbing framework for network requests."
77
s.description = <<-DESC

OHHTTPStubs/OHHTTPStubsResponse+JSON.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@ + (instancetype)responseWithJSONObject:(id)jsonObject
1818
{
1919
if (!httpHeaders[@"Content-Type"])
2020
{
21-
// If httpHeaders is nil, we can't make a mutable copy.
22-
NSMutableDictionary *mutableHeaders = httpHeaders ? [httpHeaders mutableCopy] : [NSMutableDictionary dictionary];
21+
NSMutableDictionary* mutableHeaders = [NSMutableDictionary dictionaryWithDictionary:httpHeaders];
2322
mutableHeaders[@"Content-Type"] = @"application/json";
24-
httpHeaders = [mutableHeaders copy]; // make immutable again
23+
httpHeaders = [NSDictionary dictionaryWithDictionary:mutableHeaders]; // make immutable again
2524
}
2625

2726
return [self responseWithData:[NSJSONSerialization dataWithJSONObject:jsonObject options:0 error:nil]
2827
statusCode:statusCode
29-
headers:httpHeaders
30-
];
28+
headers:httpHeaders];
3129
}
3230

3331
@end

0 commit comments

Comments
 (0)