Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#import "ASIHTTPRequest.h"
#import "ViewController.h"
@interface ViewController () {
- (IBAction)request:(id)sender;
@property(weak, nonatomic) IBOutlet UIWebView *webView;
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL *url = [NSURL URLWithString:@""];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:urlRequest];
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
- (void)viewDidUnload {
[self setWebView:nil];
[super viewDidUnload];
- (IBAction)request:(id)sender {
NSHTTPCookie *cookie;
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [cookieJar cookies]) {
NSLog(@"%@", cookie);
NSURL *httpUrl = [NSURL URLWithString:@""];
__weak ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:httpUrl];
[request setValidatesSecureCertificate:NO];
[request setPersistentConnectionTimeoutSeconds:10];
[request setCompletionBlock:^{
// Use when fetching text data
NSArray *cookies = [request responseCookies];
NSLog(@"responseCookie - %@", cookies.description);
NSLog(@"responseString - %@", [request responseString]);
[request setFailedBlock:^{
NSError *error = [request error];
NSLog(@"error - %@", [error localizedDescription]);
[request startAsynchronous];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment