Skip to content

Instantly share code, notes, and snippets.


Ben Copsey pokeb

View GitHub Profile
View ASIHTTPRequest custom run loop mode test
// 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:
// Portions are based on the ImageClient example from Apple:
View Example of creating a simple container for binary files, and parsing it
- (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]];
pokeb / gist:159641
Created Aug 1, 2009
Rough example showing download bandwidth throttling with ASIHTTPRequest
View gist:159641
- (void)handleBytesAvailable
if (![self responseHeaders]) {
if ([self readResponseHeadersReturningAuthenticationFailure]) {
[self attemptToApplyCredentialsAndResume];
if ([self needsRedirect]) {
pokeb / gist:150447
Created Jul 20, 2009
An example showing how to manage a queue with ASIHTTPRequest
View gist:150447
// 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;
pokeb / HTTP Cookie header parser
Created Sep 13, 2008
Quick and dirty HTTP cookie header parser in PHP
View HTTP Cookie header parser