root / asi-http-request-with-pithos / Classes / ASIWebPageRequest / ASIWebPageRequest.h @ 32017ec6
History | View | Annotate | Download (3.5 kB)
1 |
//
|
---|---|
2 |
// ASIWebPageRequest.h
|
3 |
// Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
|
4 |
//
|
5 |
// Created by Ben Copsey on 29/06/2010.
|
6 |
// Copyright 2010 All-Seeing Interactive. All rights reserved.
|
7 |
//
|
8 |
// This is an EXPERIMENTAL class - use at your own risk!
|
9 |
// It is strongly recommend to set a downloadDestinationPath when using ASIWebPageRequest
|
10 |
// Also, performance will be better if your ASIWebPageRequest has a downloadCache setup
|
11 |
// Known issue: You cannot use startSychronous with an ASIWebPageRequest
|
12 |
|
13 |
#import "ASIHTTPRequest.h" |
14 |
#import <libxml/HTMLparser.h>
|
15 |
#import <libxml/xmlsave.h>
|
16 |
#import <libxml/xpath.h>
|
17 |
#import <libxml/xpathInternals.h>
|
18 |
|
19 |
@class ASINetworkQueue;
|
20 |
|
21 |
// Used internally for storing what type of data we got from the server
|
22 |
typedef enum _ASIWebContentType { |
23 |
ASINotParsedWebContentType = 0,
|
24 |
ASIHTMLWebContentType = 1,
|
25 |
ASICSSWebContentType = 2
|
26 |
} ASIWebContentType; |
27 |
|
28 |
// These correspond with the urlReplacementMode property of ASIWebPageRequest
|
29 |
typedef enum _ASIURLReplacementMode { |
30 |
|
31 |
// Don't modify html or css content at all
|
32 |
ASIDontModifyURLs = 0,
|
33 |
|
34 |
// Replace external resources urls (images, stylesheets etc) with data uris, so their content is embdedded directly in the html/css
|
35 |
ASIReplaceExternalResourcesWithData = 1,
|
36 |
|
37 |
// Replace external resource urls with the url of locally cached content
|
38 |
// You must set the baseURL of a WebView / UIWebView to a file url pointing at the downloadDestinationPath of the main ASIWebPageRequest if you want to display your content
|
39 |
// See the Mac or iPhone example projects for a demonstration of how to do this
|
40 |
// The hrefs of all hyperlinks are changed to use absolute urls when using this mode
|
41 |
ASIReplaceExternalResourcesWithLocalURLs = 2
|
42 |
} ASIURLReplacementMode; |
43 |
|
44 |
|
45 |
|
46 |
@interface ASIWebPageRequest : ASIHTTPRequest {
|
47 |
|
48 |
// Each ASIWebPageRequest for an HTML or CSS file creates its own internal queue to download external resources
|
49 |
ASINetworkQueue *externalResourceQueue; |
50 |
|
51 |
// This dictionary stores a list of external resources to download, along with their content-type data or a path to the data
|
52 |
NSMutableDictionary *resourceList; |
53 |
|
54 |
// Used internally for parsing HTML (with libxml)
|
55 |
xmlDocPtr doc; |
56 |
|
57 |
// If the response is an HTML or CSS file, this will be set so the content can be correctly parsed when it has finished fetching external resources
|
58 |
ASIWebContentType webContentType; |
59 |
|
60 |
// Stores a reference to the ASIWebPageRequest that created this request
|
61 |
// Note that a parentRequest can also have a parent request because ASIWebPageRequests parse their contents to look for external resources recursively
|
62 |
// For example, a request for an image can be created by a request for a stylesheet which was created by a request for a web page
|
63 |
ASIWebPageRequest *parentRequest; |
64 |
|
65 |
// Controls what ASIWebPageRequest does with external resources. See the notes above for more.
|
66 |
ASIURLReplacementMode urlReplacementMode; |
67 |
} |
68 |
|
69 |
// Will return a data URI that contains a base64 version of the content at this url
|
70 |
// This is used when replacing urls in the html and css with actual data
|
71 |
// If you subclass ASIWebPageRequest, you can override this function to return different content or a url pointing at another location
|
72 |
- (NSString *)contentForExternalURL:(NSString *)theURL; |
73 |
|
74 |
// Returns the location that a downloaded external resource's content will be stored in
|
75 |
- (NSString *)cachePathForRequest:(ASIWebPageRequest *)theRequest; |
76 |
|
77 |
|
78 |
@property (retain, nonatomic) ASIWebPageRequest *parentRequest;
|
79 |
@property (assign, nonatomic) ASIURLReplacementMode urlReplacementMode;
|
80 |
@end
|