@@ -49,12 +49,12 @@ * FIXME: Key normalization replaces headers like "DNT" with "Dnt". * FIXME: Errors are not reported to the user. */ @interface OFHTTPServer () -- (bool)of_socket: (OF_KINDOF(OFTCPSocket *))sock - didAcceptSocket: (OF_KINDOF(OFTCPSocket *))clientSocket +- (bool)of_socket: (OFTCPSocket *)sock + didAcceptSocket: (OFTCPSocket *)clientSocket context: (id)context exception: (id)exception; @end @interface OFHTTPServerResponse: OFHTTPResponse @@ -68,11 +68,11 @@ - (instancetype)initWithSocket: (OF_KINDOF(OFTCPSocket *))sock server: (OFHTTPServer *)server request: (OFHTTPRequest *)request; @end -@interface OFHTTPServer_Connection: OFObject +@interface OFHTTPServer_Connection: OFObject { @public OF_KINDOF(OFTCPSocket *) _socket; OFHTTPServer *_server; OFTimer *_timer; @@ -90,14 +90,10 @@ OFStream *_requestBody; } - (instancetype)initWithSocket: (OF_KINDOF(OFTCPSocket *))sock server: (OFHTTPServer *)server; -- (bool)socket: (OF_KINDOF(OFTCPSocket *))sock - didReadLine: (OFString *)line - context: (id)context - exception: (id)exception; - (bool)parseProlog: (OFString *)line; - (bool)parseHeaders: (OFString *)line; - (bool)sendErrorAndClose: (short)statusCode; - (void)createResponse; @end @@ -407,16 +403,14 @@ [_requestBody release]; [super dealloc]; } -- (bool)socket: (OF_KINDOF(OFTCPSocket *))sock +- (bool)stream: (OF_KINDOF(OFStream *))sock didReadLine: (OFString *)line - context: (id)context - exception: (id)exception { - if (line == nil || exception != nil) + if (line == nil) return false; @try { switch (_state) { case AWAITING_PROLOG: @@ -798,12 +792,12 @@ [_listeningSocket cancelAsyncRequests]; [_listeningSocket release]; _listeningSocket = nil; } -- (bool)of_socket: (OF_KINDOF(OFTCPSocket *))sock - didAcceptSocket: (OF_KINDOF(OFTCPSocket *))clientSocket +- (bool)of_socket: (OFTCPSocket *)sock + didAcceptSocket: (OFTCPSocket *)clientSocket context: (id)context exception: (id)exception { OFHTTPServer_Connection *connection; @@ -818,13 +812,11 @@ connection = [[[OFHTTPServer_Connection alloc] initWithSocket: clientSocket server: self] autorelease]; - [clientSocket asyncReadLineWithTarget: connection - selector: @selector(socket:didReadLine: - context:exception:) - context: nil]; + [clientSocket setDelegate: connection]; + [clientSocket asyncReadLine]; return true; } @end