396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
didReadIntoBuffer: (const char*)buffer
length: (size_t)length
exception: (OFException*)exception
{
if ([sock_ isAtEndOfStream] || exception != nil)
return NO;
[POSTData addItemsFromCArray: buffer
count: length];
if ([POSTData count] >= contentLength) {
@try {
[self sendReply];
} @catch (OFWriteFailedException *e) {
return NO;
}
|
|
|
|
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
didReadIntoBuffer: (const char*)buffer
length: (size_t)length
exception: (OFException*)exception
{
if ([sock_ isAtEndOfStream] || exception != nil)
return NO;
[POSTData addItems: buffer
count: length];
if ([POSTData count] >= contentLength) {
@try {
[self sendReply];
} @catch (OFWriteFailedException *e) {
return NO;
}
|
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
while ((key = [keyEnumerator nextObject]) != nil &&
(value = [valueEnumerator nextObject]) != nil)
[sock writeFormat: @"%@: %@\r\n", key, value];
[sock writeString: @"\r\n"];
if (requestType != OF_HTTP_REQUEST_TYPE_HEAD)
[sock writeBuffer: [replyData cArray]
length: [replyData count] * [replyData itemSize]];
}
@end
@implementation OFHTTPServer
+ (instancetype)server
{
|
|
|
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
while ((key = [keyEnumerator nextObject]) != nil &&
(value = [valueEnumerator nextObject]) != nil)
[sock writeFormat: @"%@: %@\r\n", key, value];
[sock writeString: @"\r\n"];
if (requestType != OF_HTTP_REQUEST_TYPE_HEAD)
[sock writeBuffer: [replyData items]
length: [replyData count] * [replyData itemSize]];
}
@end
@implementation OFHTTPServer
+ (instancetype)server
{
|