Just wrote this quick and dirty method that dumps a ASIHTTPReqeust on console as a curl command. You can add it to your project as a category extension on ASIHTTPRequest or on a subclass (if you have one).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
-(NSString*) description
{
    __block NSMutableString *displayString = [NSMutableString stringWithFormat:@"\nRequest\n-------\ncurl -X %@", self.requestMethod];
 
    [[self requestHeaders] enumerateKeysAndObjectsUsingBlock:^(id key, id val, BOOL *stop) {
 
        [displayString appendFormat:@" -H \"%@: %@\"", key, val];
    }];
 
    [displayString appendFormat:@" \"%@\"",  [self.url absoluteString]];
 
    if([self.requestMethod isEqualToString:@"POST"]) {
 
        NSString *bodyString = [[[NSString alloc] initWithData:self.postBody 
                                                      encoding:NSUTF8StringEncoding] autorelease];
        [displayString appendFormat:@" -d \"%@\"", bodyString];        
    }
 
    if(self.responseString) {
        [displayString appendFormat:@"\n--------\nResponse\n--------\n%@\n", self.responseString];
    }
    return displayString;
}




Mugunth

Follow me on Twitter

Related posts:

  1. Easy Debugging with NSMutableURLRequest This post is a sequel to one of my previous...