<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -343,6 +343,12 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
 // Returns true if the response was gzip compressed
 - (BOOL)isResponseCompressed;
 
+#pragma mark running a request
+
+// Run a request asynchronously by adding it to the global queue
+// (Use [request start] for a synchronous request)
+- (void)startAsynchronous;
+
 #pragma mark request logic
 
 // Main request loop is in here
@@ -418,7 +424,11 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
 - (void)handleStreamComplete;
 - (void)handleStreamError;
 
-# pragma mark session credentials
+#pragma mark global queue
+
++ (NSOperationQueue *)sharedRequestQueue;
+
+#pragma mark session credentials
 
 + (NSMutableArray *)sessionProxyCredentialsStore;
 + (NSMutableArray *)sessionCredentialsStore;</diff>
      <filename>Classes/ASIHTTPRequest.h</filename>
    </modified>
    <modified>
      <diff>@@ -93,6 +93,8 @@ static NSRecursiveLock *sessionCookiesLock = nil;
 // This is so it can make use of any credentials supplied for the other request, if they are appropriate
 static NSRecursiveLock *delegateAuthenticationLock = nil;
 
+static NSOperationQueue *sharedRequestQueue = nil;
+
 // Private stuff
 @interface ASIHTTPRequest ()
 
@@ -403,6 +405,15 @@ static NSRecursiveLock *delegateAuthenticationLock = nil;
 	}
 }
 
+#pragma mark running a request
+
+// Run a request asynchronously by adding it to the global queue
+// (Use [request start] for a synchronous request)
+- (void)startAsynchronous
+{
+	[[ASIHTTPRequest sharedRequestQueue] addOperation:self];
+}
+
 
 #pragma mark request logic
 
@@ -2088,6 +2099,17 @@ static NSRecursiveLock *delegateAuthenticationLock = nil;
     [super cancel];
 }
 
+#pragma mark global queue
+
++ (NSOperationQueue *)sharedRequestQueue
+{
+	if (!sharedRequestQueue) {
+		sharedRequestQueue = [[NSOperationQueue alloc] init];
+		[sharedRequestQueue setMaxConcurrentOperationCount:YES];
+	}
+	return sharedRequestQueue;
+}
+
 # pragma mark session credentials
 
 + (NSMutableArray *)sessionProxyCredentialsStore</diff>
      <filename>Classes/ASIHTTPRequest.m</filename>
    </modified>
    <modified>
      <diff>@@ -923,7 +923,64 @@
 	GHAssertTrue(success,@&quot;Got wrong response status message&quot;);
 }
 
+- (void)testAsynchronousWithGlobalQueue
+{
+	ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@&quot;http://allseeing-i.com/ASIHTTPRequest/tests/first&quot;]];
+	[request setUserInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:1] forKey:@&quot;RequestNumber&quot;]];
+	[request setDidFailSelector:@selector(asyncFail:)];
+	[request setDidFinishSelector:@selector(asyncSuccess:)];
+	[request setDelegate:self];
+	[request startAsynchronous];
+	
+	request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@&quot;http://allseeing-i.com/ASIHTTPRequest/tests/second&quot;]];
+	[request setUserInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:2] forKey:@&quot;RequestNumber&quot;]];
+	[request setDidFailSelector:@selector(asyncFail:)];
+	[request setDidFinishSelector:@selector(asyncSuccess:)];
+	[request setDelegate:self];
+	[request startAsynchronous];
+	
+	request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@&quot;http://allseeing-i.com/ASIHTTPRequest/tests/third&quot;]];
+	[request setUserInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:3] forKey:@&quot;RequestNumber&quot;]];
+	[request setDidFailSelector:@selector(asyncFail:)];
+	[request setDidFinishSelector:@selector(asyncSuccess:)];
+	[request setDelegate:self];
+	[request startAsynchronous];	
+	
+	request = [ASIHTTPRequest requestWithURL:nil];
+	[request setUserInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:4] forKey:@&quot;RequestNumber&quot;]];
+	[request setDidFailSelector:@selector(asyncFail:)];
+	[request setDidFinishSelector:@selector(asyncSuccess:)];
+	[request setDelegate:self];
+	[request startAsynchronous];	
+}
 
-@end
+
+- (void)asyncFail:(ASIHTTPRequest *)request
+{
+	int requestNumber = [[[request userInfo] objectForKey:@&quot;RequestNumber&quot;] intValue];
+	GHAssertEquals(requestNumber,4,@&quot;Wrong request failed&quot;);	
+}
+
+- (void)asyncSuccess:(ASIHTTPRequest *)request
+{
+	int requestNumber = [[[request userInfo] objectForKey:@&quot;RequestNumber&quot;] intValue];
+	GHAssertNotEquals(requestNumber,4,@&quot;Request succeeded when it should have failed&quot;);
+	
+	BOOL success;
+	switch (requestNumber) {
+		case 1:
+			success = [[request responseString] isEqualToString:@&quot;This is the expected content for the first string&quot;];
+			break;
+		case 2:
+			success = [[request responseString] isEqualToString:@&quot;This is the expected content for the second string&quot;];
+			break;
+		case 3:
+			success = [[request responseString] isEqualToString:@&quot;This is the expected content for the third string&quot;];
+			break;
+	}
+	GHAssertTrue(success,@&quot;Got wrong request content - very bad!&quot;);
+	
+}
 
 
+@end
\ No newline at end of file</diff>
      <filename>Classes/Tests/ASIHTTPRequestTests.m</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8017db2ad6eb7d7131df13d4a34e56f716cb14dc</id>
    </parent>
  </parents>
  <author>
    <name>Ben Copsey</name>
    <email>ben@allseeing-i.com</email>
  </author>
  <url>http://github.com/pokeb/asi-http-request/commit/d310696cb9b5116b3b888e94dbd4cc94e8bd32af</url>
  <id>d310696cb9b5116b3b888e94dbd4cc94e8bd32af</id>
  <committed-date>2009-10-06T02:50:30-07:00</committed-date>
  <authored-date>2009-10-06T02:50:30-07:00</authored-date>
  <message>Added [request startAsynchronous] for easy async requests (no queue required!)</message>
  <tree>1292e00a0b3fb30301de9cda625b9e3c5764e109</tree>
  <committer>
    <name>Ben Copsey</name>
    <email>ben@allseeing-i.com</email>
  </committer>
</commit>
