<commit_before>__*Important note if your project doesn't use ARC*: you must add the @-fobjc-arc@ compiler flag to @SVHTTPRequest.m@ in Target Settings > Build Phases > Compile Sources.__

h1. SVHTTPRequest

SVHTTPRequest is a simple and extremely straightforward way to communicate with RESTful web APIs for iOS and Mac. It's a simpler and cleaner alternative to bulky "ASIHTTPRequest":https://github.com/pokeb/asi-http-request/tree, "AFNetworking":https://github.com/AFNetworking/AFNetworking and "RESTKit":https://github.com/RestKit/RestKit. It is blocked-based, uses @NSURLConnection@, ARC, as well as @NSJSONSerialization@ to automatically parse JSON responses (making it only compatible with iOS 5 and Mac OS X Lion).

**SVHTTPRequest features:**

* straightforward singleton convenience methods for making @GET@, @POST@, @PUT@, @DELETE@, @HEAD@ and download requests.
* completion block handler returning @response@ (@NSObject@ if JSON, otherwise @NSData@), @NSHTTPURLResponse@ and @NSError@ objects.
* persistent @basePath@ and basic authentication signing when using @SVHTTPClient@.
* support for @multipart/form-data@ parameters in POST and PUT requests.
* talks with the network activity indicator (iOS only).

h2. Installation

* Drag the @SVHTTPRequest/SVHTTPRequest@ folder into your project. 
* @#import "SVHTTPRequest.h"@ (this will import @SVHTTPClient@ as well)

h2. Usage

(see sample Xcode project in @/Demo@)

The easiest way to make a request is using the @SVHTTPRequest@ convenience methods:

<pre>
[SVHTTPRequest GET:@"http://github.com/api/v2/json/repos/show/samvermette/SVHTTPRequest"
        parameters:nil
        completion:^(id response, NSHTTPURLResponse *urlResponse, NSError *error) {
            NSLog(@"SVHTTPRequest has %@ watchers", [[response valueForKey:@"repository"] valueForKey:@"watchers"]];
        }];
</pre>

If most of your requests are made to the same API endpoint, you should instead use @SVHTTPClient@ so you can set parameters (@basePath@, @cachePolicy@, @sendParametersAsJSON@, @"userAgent@) that will be used for each request:

<pre>
[[SVHTTPClient sharedClient] setBasePath:@"http://api.twitter.com/1/"];

[[SVHTTPClient sharedClient] GET:@"users/show.json"
                      parameters:[NSDictionary dictionaryWithObject:@"samvermette" forKey:@"screen_name"]
                      completion:^(id response, NSHTTPURLResponse *urlResponse, NSError *error) {
                          followersLabel.text = [NSString stringWithFormat:@"@samvermette has %@ followers", [response valueForKey:@"followers_count"]];
                      }];
</pre> 

If you would like to set those properties on individual requests, you'll need to alloc/init the request, set the attributes, and then call @start@:

<pre>
SVHTTPRequest *request = [[SVHTTPRequest alloc] initWithAddress:@"http://github.com/api/v2/json/repos/show/samvermette/SVHTTPRequest"
                                                         method:SVHTTPRequestMethodGET 
                                                     parameters:nil 
                                                     completion:^(id response, NSHTTPURLResponse *urlResponse, NSError *error) {
                                                         watchersLabel.text = [NSString stringWithFormat:@"SVHTTPRequest has %@ watchers", [[response valueForKey:@"repository"] valueForKey:@"watchers"]];
                                                     }];
request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
[request start];
</pre>


h3. Making a download request<commit_msg>Fix broken GitHub request in README.<commit_after>__*Important note if your project doesn't use ARC*: you must add the @-fobjc-arc@ compiler flag to @SVHTTPRequest.m@ in Target Settings > Build Phases > Compile Sources.__

h1. SVHTTPRequest

SVHTTPRequest is a simple and extremely straightforward way to communicate with RESTful web APIs for iOS and Mac. It's a simpler and cleaner alternative to bulky "ASIHTTPRequest":https://github.com/pokeb/asi-http-request/tree, "AFNetworking":https://github.com/AFNetworking/AFNetworking and "RESTKit":https://github.com/RestKit/RestKit. It is blocked-based, uses @NSURLConnection@, ARC, as well as @NSJSONSerialization@ to automatically parse JSON responses (making it only compatible with iOS 5 and Mac OS X Lion).

**SVHTTPRequest features:**

* straightforward singleton convenience methods for making @GET@, @POST@, @PUT@, @DELETE@, @HEAD@ and download requests.
* completion block handler returning @response@ (@NSObject@ if JSON, otherwise @NSData@), @NSHTTPURLResponse@ and @NSError@ objects.
* persistent @basePath@ and basic authentication signing when using @SVHTTPClient@.
* support for @multipart/form-data@ parameters in POST and PUT requests.
* talks with the network activity indicator (iOS only).

h2. Installation

* Drag the @SVHTTPRequest/SVHTTPRequest@ folder into your project. 
* @#import "SVHTTPRequest.h"@ (this will import @SVHTTPClient@ as well)

h2. Usage

(see sample Xcode project in @/Demo@)

The easiest way to make a request is using the @SVHTTPRequest@ convenience methods:

<pre>
[SVHTTPRequest GET:@"https://api.github.com/repos/samvermette/SVHTTPRequest"
        parameters:nil
        completion:^(id response, NSHTTPURLResponse *urlResponse, NSError *error) {
            watchersLabel.text = [NSString stringWithFormat:@"SVHTTPRequest has %@ watchers", [response valueForKey:@"watchers"]];
        }];
</pre>

If most of your requests are made to the same API endpoint, you should instead use @SVHTTPClient@ so you can set parameters (@basePath@, @cachePolicy@, @sendParametersAsJSON@, @"userAgent@) that will be used for each request:

<pre>
[[SVHTTPClient sharedClient] setBasePath:@"http://api.twitter.com/1/"];

[[SVHTTPClient sharedClient] GET:@"users/show.json"
                      parameters:[NSDictionary dictionaryWithObject:@"samvermette" forKey:@"screen_name"]
                      completion:^(id response, NSHTTPURLResponse *urlResponse, NSError *error) {
                          followersLabel.text = [NSString stringWithFormat:@"@samvermette has %@ followers", [response valueForKey:@"followers_count"]];
                      }];
</pre> 

If you would like to set those properties on individual requests, you'll need to alloc/init the request, set the attributes, and then call @start@:

<pre>
SVHTTPRequest *request = [[SVHTTPRequest alloc] initWithAddress:@"http://github.com/api/v2/json/repos/show/samvermette/SVHTTPRequest"
                                                         method:SVHTTPRequestMethodGET 
                                                     parameters:nil 
                                                     completion:^(id response, NSHTTPURLResponse *urlResponse, NSError *error) {
                                                         watchersLabel.text = [NSString stringWithFormat:@"SVHTTPRequest has %@ watchers", [[response valueForKey:@"repository"] valueForKey:@"watchers"]];
                                                     }];
request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
[request start];
</pre>


h3. Making a download request
{'fraction_non_alphanumeric': 0.10115808567043394, 'fraction_numerical': 0.002092925910422771, 'mean_word_length': 3.320675105485232, 'pattern_counts': {'":': 6, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1492585', 'n_tokens_mistral': 1946, 'n_tokens_neox': 1828, 'n_words': 619}