Created
May 5, 2015 04:05
-
-
Save MKSG-MugunthKumar/5cda35464a93c7aca378 to your computer and use it in GitHub Desktop.
NSURLRequest cURL description
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)description { | |
__block NSMutableString *displayString = [NSMutableString stringWithFormat:@"curl -v -X %@", self.HTTPMethod]; | |
[displayString appendFormat:@" \'%@\'", self.URL.absoluteString]; | |
[self.allHTTPHeaderFields enumerateKeysAndObjectsUsingBlock:^(id key, id val, BOOL *stop) { | |
[displayString appendFormat:@" -H \'%@: %@\'", key, val]; | |
}]; | |
if ([self.HTTPMethod isEqualToString:@"POST"] || | |
[self.HTTPMethod isEqualToString:@"PUT"] || | |
[self.HTTPMethod isEqualToString:@"PATCH"]) { | |
[displayString appendFormat:@" -d \'%@\'", | |
[[NSString alloc] initWithData:self.HTTPBody encoding:NSUTF8StringEncoding]]; | |
} | |
return displayString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment