Differences From Artifact [814464cd03]:
- File src/OFHTTPServer.m — part of check-in [2b6a12065e] at 2018-12-08 16:53:30 on branch trunk — Separate error methods for async method delegates (user: js, size: 17613) [annotate] [blame] [check-ins using]
To Artifact [aae9d41f78]:
- File
src/OFHTTPServer.m
— part of check-in
[064dbe5127]
at
2018-12-11 22:57:46
on branch trunk
— Include an exception in delegate methods
Otherwise, there would be two methods for every operation: One for
success and one for failure. It also makes it easy to forget about
handling failure, so it's better to always pass an optional exception. (user: js, size: 17630) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
399 400 401 402 403 404 405 406 |
[_requestBody release];
[super dealloc];
}
- (bool)stream: (OF_KINDOF(OFStream *))sock
didReadLine: (OFString *)line
{
| > | | 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
[_requestBody release];
[super dealloc];
}
- (bool)stream: (OF_KINDOF(OFStream *))sock
didReadLine: (OFString *)line
exception: (id)exception
{
if (line == nil || exception != nil)
return false;
@try {
switch (_state) {
case AWAITING_PROLOG:
return [self parseProlog: line];
case PARSING_HEADERS:
|
| ︙ | ︙ | |||
785 786 787 788 789 790 791 792 |
[_listeningSocket cancelAsyncRequests];
[_listeningSocket release];
_listeningSocket = nil;
}
- (bool)socket: (OF_KINDOF(OFTCPSocket *))sock
didAcceptSocket: (OF_KINDOF(OFTCPSocket *))acceptedSocket
{
| > | > > > > > > > > > > > < < < < < < < < < < | 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 |
[_listeningSocket cancelAsyncRequests];
[_listeningSocket release];
_listeningSocket = nil;
}
- (bool)socket: (OF_KINDOF(OFTCPSocket *))sock
didAcceptSocket: (OF_KINDOF(OFTCPSocket *))acceptedSocket
exception: (id)exception
{
OFHTTPServer_Connection *connection;
if (exception != nil) {
if (![_delegate respondsToSelector:
@selector(server:didReceiveExceptionOnListeningSocket:)])
return false;
return [_delegate server: self
didReceiveExceptionOnListeningSocket: exception];
}
connection = [[[OFHTTPServer_Connection alloc]
initWithSocket: acceptedSocket
server: self] autorelease];
[(OFTCPSocket *)acceptedSocket setDelegate: connection];
[acceptedSocket asyncReadLine];
return true;
}
@end
|