ObjFW  Diff

Differences From Artifact [fc3a0af468]:

To Artifact [661e4352a9]:


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#import "OFData.h"
#import "OFLocalization.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFURL.h"
#ifdef OF_HAVE_SOCKETS
# import "OFHTTPClient.h"
# import "OFHTTPRequest.h"
# import "OFHTTPResponse.h"
#endif
#import "OFXMLElement.h"

#ifdef OF_HAVE_SOCKETS
# import "OFHTTPRequestFailedException.h"
#endif
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"







<
<
<
<
<


<
<
<







37
38
39
40
41
42
43





44
45



46
47
48
49
50
51
52
#import "OFData.h"
#import "OFLocalization.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFURL.h"





#import "OFXMLElement.h"




#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
	if ([scheme isEqual: @"file"]) {
		if (encoding == OF_STRING_ENCODING_AUTODETECT)
			encoding = OF_STRING_ENCODING_UTF_8;

		self = [self initWithContentsOfFile: [URL path]
					   encoding: encoding];
	} else
# endif
# ifdef OF_HAVE_SOCKETS
	if ([scheme isEqual: @"http"] || [scheme isEqual: @"https"]) {
		bool mutable = [self isKindOfClass: [OFMutableString class]];
		OFHTTPClient *client = [OFHTTPClient client];
		OFHTTPRequest *request = [OFHTTPRequest requestWithURL: URL];
		OFHTTPResponse *response = [client performRequest: request];

		if ([response statusCode] != 200)
			@throw [OFHTTPRequestFailedException
			    exceptionWithRequest: request
					response: response];

		[self release];

		if (mutable)
			self = [[response string] mutableCopy];
		else
			self = [[response string] copy];
	} else
# endif
		@throw [OFUnsupportedProtocolException exceptionWithURL: URL];

	objc_autoreleasePoolPop(pool);

	return self;
}







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







1040
1041
1042
1043
1044
1045
1046




















1047
1048
1049
1050
1051
1052
1053
	if ([scheme isEqual: @"file"]) {
		if (encoding == OF_STRING_ENCODING_AUTODETECT)
			encoding = OF_STRING_ENCODING_UTF_8;

		self = [self initWithContentsOfFile: [URL path]
					   encoding: encoding];
	} else




















# endif
		@throw [OFUnsupportedProtocolException exceptionWithURL: URL];

	objc_autoreleasePoolPop(pool);

	return self;
}