41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#import "autorelease.h"
#import "macros.h"
Class of_http_client_tls_socket_class = Nil;
static OF_INLINE void
normalizeKey(char *str)
{
BOOL firstLetter = YES;
while (*str != '\0') {
if (!isalnum(*str)) {
firstLetter = YES;
str++;
|
|
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#import "autorelease.h"
#import "macros.h"
Class of_http_client_tls_socket_class = Nil;
static OF_INLINE void
normalize_key(char *str)
{
BOOL firstLetter = YES;
while (*str != '\0') {
if (!isalnum(*str)) {
firstLetter = YES;
str++;
|
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];
serverHeaders = [OFMutableDictionary dictionary];
for (;;) {
OFString *key, *value;
const char *line_c, *tmp;
char *key_c;
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
}
if (line == nil)
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
if ([line isEqual: @""])
break;
line_c = [line UTF8String];
if ((tmp = strchr(line_c, ':')) == NULL)
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
if ((key_c = malloc(tmp - line_c + 1)) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: [self class]
requestedSize: tmp - line_c + 1];
memcpy(key_c, line_c, tmp - line_c);
key_c[tmp - line_c] = '\0';
normalizeKey(key_c);
@try {
key = [OFString stringWithUTF8StringNoCopy: key_c
freeWhenDone: YES];
} @catch (id e) {
free(key_c);
}
do {
tmp++;
} while (*tmp == ' ');
value = [OFString stringWithUTF8String: tmp];
|
|
|
|
|
|
|
|
|
|
|
|
|
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];
serverHeaders = [OFMutableDictionary dictionary];
for (;;) {
OFString *key, *value;
const char *lineC, *tmp;
char *keyC;
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
}
if (line == nil)
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
if ([line isEqual: @""])
break;
lineC = [line UTF8String];
if ((tmp = strchr(lineC, ':')) == NULL)
@throw [OFInvalidServerReplyException
exceptionWithClass: [self class]];
if ((keyC = malloc(tmp - lineC + 1)) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: [self class]
requestedSize: tmp - lineC + 1];
memcpy(keyC, lineC, tmp - lineC);
keyC[tmp - lineC] = '\0';
normalize_key(keyC);
@try {
key = [OFString stringWithUTF8StringNoCopy: keyC
freeWhenDone: YES];
} @catch (id e) {
free(keyC);
}
do {
tmp++;
} while (*tmp == ' ');
value = [OFString stringWithUTF8String: tmp];
|