︙ | | | ︙ | |
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#import "OFSystemInfo.h"
#ifdef OF_HAVE_SOCKETS
# import "OFHTTPRequestFailedException.h"
#endif
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#import "OFUnsupportedProtocolException.h"
#import "base64.h"
|
>
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#import "OFSystemInfo.h"
#ifdef OF_HAVE_SOCKETS
# import "OFHTTPRequestFailedException.h"
#endif
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFInvalidServerReplyException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#import "OFUnsupportedProtocolException.h"
#import "base64.h"
|
︙ | | | ︙ | |
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
{
@try {
OFFile *file = [[OFFile alloc] initWithPath: path
mode: @"rb"];
of_offset_t size = [[OFFileManager defaultManager]
sizeOfFileAtPath: path];
if (size > SIZE_MAX)
@throw [OFOutOfRangeException exception];
self = [self initWithItemSize: 1
capacity: (size_t)size];
@try {
size_t pageSize = [OFSystemInfo pageSize];
|
>
|
|
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
{
@try {
OFFile *file = [[OFFile alloc] initWithPath: path
mode: @"rb"];
of_offset_t size = [[OFFileManager defaultManager]
sizeOfFileAtPath: path];
if (sizeof(of_offset_t) > sizeof(size_t) &&
size > (of_offset_t)SIZE_MAX)
@throw [OFOutOfRangeException exception];
self = [self initWithItemSize: 1
capacity: (size_t)size];
@try {
size_t pageSize = [OFSystemInfo pageSize];
|
︙ | | | ︙ | |
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
OFHTTPRequest *request = [OFHTTPRequest
requestWithURL: URL];
OFHTTPResponse *response = [client
performRequest: request];
size_t pageSize;
char *buffer;
OFDictionary *headers;
OFString *contentLength;
if ([response statusCode] != 200)
@throw [OFHTTPRequestFailedException
exceptionWithRequest: request
response: response];
pageSize = [OFSystemInfo pageSize];
|
|
|
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
OFHTTPRequest *request = [OFHTTPRequest
requestWithURL: URL];
OFHTTPResponse *response = [client
performRequest: request];
size_t pageSize;
char *buffer;
OFDictionary *headers;
OFString *contentLengthString;
if ([response statusCode] != 200)
@throw [OFHTTPRequestFailedException
exceptionWithRequest: request
response: response];
pageSize = [OFSystemInfo pageSize];
|
︙ | | | ︙ | |
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
count: length];
}
} @finally {
[self freeMemory: buffer];
}
headers = [response headers];
if ((contentLength =
[headers objectForKey: @"Content-Length"]) != nil)
if ([self count] !=
[contentLength decimalValue])
@throw [OFTruncatedDataException
exception];
} @catch (id e) {
[self release];
@throw e;
}
} else
# endif
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
|
|
|
>
>
>
>
>
>
>
|
|
>
|
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
count: length];
}
} @finally {
[self freeMemory: buffer];
}
headers = [response headers];
if ((contentLengthString =
[headers objectForKey: @"Content-Length"]) != nil) {
intmax_t contentLength =
[contentLengthString decimalValue];
if (contentLength < 0)
@throw [OFInvalidServerReplyException
exception];
if ((uintmax_t)[self count] !=
(uintmax_t)contentLength)
@throw [OFTruncatedDataException
exception];
}
} @catch (id e) {
[self release];
@throw e;
}
} else
# endif
@throw [OFUnsupportedProtocolException exceptionWithURL: URL];
|
︙ | | | ︙ | |