예제 #1
0
void HTTPSocket<isServer>::onEnd(uS::Socket s) {
    s.cancelTimeout();

    Data *httpSocketData = (Data *) s.getSocketData();
    s.close();

    if (!isServer) {
        ((Group<CLIENT> *) httpSocketData->nodeData)->errorHandler(httpSocketData->httpUser);
    }

    delete httpSocketData;
}
예제 #2
0
void HttpSocket<isServer>::onEnd(uS::Socket s) {
    if (!s.isShuttingDown()) {
        if (isServer) {
            getGroup<isServer>(s)->removeHttpSocket(HttpSocket<isServer>(s));
            getGroup<isServer>(s)->httpDisconnectionHandler(HttpSocket<isServer>(s));
        }
    } else {
        s.cancelTimeout();
    }

    Data *httpSocketData = (Data *) s.getSocketData();

    s.close();

    while (!httpSocketData->messageQueue.empty()) {
        uS::SocketData::Queue::Message *message = httpSocketData->messageQueue.front();
        if (message->callback) {
            message->callback(nullptr, message->callbackData, true, nullptr);
        }
        httpSocketData->messageQueue.pop();
    }

    while (httpSocketData->outstandingResponsesHead) {
        getGroup<isServer>(s)->httpCancelledRequestHandler(httpSocketData->outstandingResponsesHead);
        HttpResponse *next = httpSocketData->outstandingResponsesHead->next;
        delete httpSocketData->outstandingResponsesHead;
        httpSocketData->outstandingResponsesHead = next;
    }

    if (httpSocketData->preAllocatedResponse) {
        delete httpSocketData->preAllocatedResponse;
    }

    if (!isServer) {
        s.cancelTimeout();
        getGroup<CLIENT>(s)->errorHandler(httpSocketData->httpUser);
    }

    delete httpSocketData;
}