Ben Copsey

Merge branch 'asiwebpagerequest' into v1.8-merge

Conflicts:
	Classes/ASIHTTPRequest.m
	Mac.xcodeproj/project.pbxproj
... ... @@ -818,7 +818,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
@property (assign,readonly) unsigned long long totalBytesRead;
@property (assign,readonly) unsigned long long totalBytesSent;
@property (assign) NSStringEncoding defaultResponseEncoding;
@property (assign,readonly) NSStringEncoding responseEncoding;
@property (assign) NSStringEncoding responseEncoding;
@property (assign) BOOL allowCompressedResponse;
@property (assign) BOOL allowResumeForFileDownloads;
@property (retain) NSDictionary *userInfo;
... ...
... ... @@ -23,6 +23,7 @@
// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.7-56 2010-08-30";
NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
... ... @@ -189,7 +190,6 @@ static NSOperationQueue *sharedQueue = nil;
@property (assign) unsigned long long contentLength;
@property (assign) unsigned long long partialDownloadSize;
@property (assign, nonatomic) unsigned long long uploadBufferSize;
@property (assign) NSStringEncoding responseEncoding;
@property (retain, nonatomic) NSOutputStream *postBodyWriteStream;
@property (retain, nonatomic) NSInputStream *postBodyReadStream;
@property (assign) unsigned long long totalBytesRead;
... ...
//
// ASIWebPageRequest.h
// Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
//
// Created by Ben Copsey on 29/06/2010.
// Copyright 2010 All-Seeing Interactive. All rights reserved.
//
// This is an EXPERIMENTAL class - use at your own risk!
// Known issue: You cannot use startSychronous with an ASIWebPageRequest
#import "ASIHTTPRequest.h"
#import <tidy/tidy.h>
#import <tidy/buffio.h>
#import <libxml/tree.h>
#import <libxml/parser.h>
#import <libxml/xpath.h>
#import <libxml/xpathInternals.h>
@class ASINetworkQueue;
typedef enum _ASIWebContentType {
ASINotParsedWebContentType = 0,
ASIHTMLWebContentType = 1,
ASICSSWebContentType = 2
} ASIWebContentType;
@interface ASIWebPageRequest : ASIHTTPRequest {
ASINetworkQueue *externalResourceQueue;
NSMutableDictionary *resourceList;
xmlDocPtr doc;
ASIWebContentType webContentType;
}
+ (NSString *)XHTMLForString:(NSString *)inputHTML error:(NSError **)error;
@end
... ...
This diff is collapsed. Click to expand it.
... ... @@ -5,6 +5,8 @@
// Copyright 2008 All-Seeing Interactive Ltd. All rights reserved.
//
#import <WebKit/WebKit.h>
@class ASIHTTPRequest;
@class ASINetworkQueue;
... ... @@ -45,6 +47,9 @@
IBOutlet NSTextField *tableLoadStatus;
NSMutableArray *rowData;
ASINetworkQueue *tableQueue;
IBOutlet WebView *webView;
IBOutlet NSTextView *webPageSource;
}
- (IBAction)simpleURLFetch:(id)sender;
... ... @@ -64,6 +69,7 @@
- (IBAction)reloadTableData:(id)sender;
- (IBAction)clearCache:(id)sender;
- (IBAction)fetchWebPage:(id)sender;
@property (retain, nonatomic) ASIHTTPRequest *bigFetchRequest;
@property (retain, nonatomic) NSMutableArray *rowData;
... ...
... ... @@ -10,6 +10,7 @@
#import "ASIFormDataRequest.h"
#import "ASINetworkQueue.h"
#import "ASIDownloadCache.h"
#import "ASIWebPageRequest.h"
@interface AppDelegate ()
- (void)updateBandwidthUsageIndicator;
... ... @@ -44,7 +45,7 @@
- (IBAction)simpleURLFetch:(id)sender
{
ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/the_great_american_novel_%28abridged%29.txt"]] autorelease];
ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com"]] autorelease];
//Customise our user agent, for no real reason
[request addRequestHeader:@"User-Agent" value:@"ASIHTTPRequest"];
... ... @@ -57,10 +58,6 @@
}
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
[htmlSource setString:[request responseString]];
}
- (IBAction)URLFetchWithProgress:(id)sender
... ... @@ -381,6 +378,30 @@
[[ASIDownloadCache sharedCache] clearCachedResponsesForStoragePolicy:ASICacheForSessionDurationCacheStoragePolicy];
}
- (IBAction)fetchWebPage:(id)sender
{
ASIWebPageRequest *request = [[[ASIWebPageRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/Who-is-using-it"]] autorelease];
[request setDidFailSelector:@selector(webPageFetchFailed:)];
[request setDidFinishSelector:@selector(webPageFetchSucceeded:)];
[request setDelegate:self];
[request setDownloadCache:[ASIDownloadCache sharedCache]];
[[ASIDownloadCache sharedCache] setDefaultCachePolicy:ASIOnlyLoadIfNotCachedCachePolicy];
[[ASIDownloadCache sharedCache] setShouldRespectCacheControlHeaders:NO];
[request startAsynchronous];
}
- (void)webPageFetchFailed:(ASIHTTPRequest *)request
{
[[NSAlert alertWithError:[request error]] runModal];
}
- (void)webPageFetchSucceeded:(ASIHTTPRequest *)request
{
[webPageSource setString:[request responseString]];
[[webView mainFrame] loadHTMLString:[request responseString] baseURL:[request url]];
}
@synthesize bigFetchRequest;
@synthesize rowData;
... ...
This diff is collapsed. Click to expand it.