View gist:150447
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
// | |
// MyController.h | |
// | |
// Created by Ben Copsey on 20/07/2009. | |
// Copyright 2009 All-Seeing Interactive. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#import <GHUnit/GHUnit.h> | |
@class ASINetworkQueue; |
View ASIHTTPRequest custom run loop mode test
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
// | |
// ASIHTTPRequest.m | |
// | |
// Created by Ben Copsey on 04/10/2007. | |
// Copyright 2007-2010 All-Seeing Interactive. All rights reserved. | |
// | |
// A guide to the main features is available at: | |
// http://allseeing-i.com/ASIHTTPRequest | |
// | |
// Portions are based on the ImageClient example from Apple: |
View Example of creating a simple container for binary files, and parsing it
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
- (void)demonstrateCustomBinaryDataParsing | |
{ | |
// Generate data in the format: | |
// name:size\n<data>name:size\n<data> | |
NSData *file1data = [NSData dataWithContentsOfFile:@"/Users/ben/Desktop/1.png"]; | |
NSData *file2data = [NSData dataWithContentsOfFile:@"/Users/ben/Desktop/2.png"]; | |
NSMutableData *payload = [NSMutableData data]; | |
NSLog([NSString stringWithFormat:@"file1:%lu\n",[file1data length]]); | |
[payload appendData:[[NSString stringWithFormat:@"file1:%lu\n",[file1data length]] dataUsingEncoding:NSASCIIStringEncoding]]; |
View gist:159641
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
- (void)handleBytesAvailable | |
{ | |
if (![self responseHeaders]) { | |
if ([self readResponseHeadersReturningAuthenticationFailure]) { | |
[self attemptToApplyCredentialsAndResume]; | |
return; | |
} | |
} | |
if ([self needsRedirect]) { |