VirtualBox

Changeset 99937 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
May 23, 2023 3:38:52 PM (19 months ago)
Author:
vboxsync
Message:

Shared Clipboard: Added new testcase for the HTTP server in combination with the Shared Clipboard API, various updates and general improvements. bugref:9437

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/http-server.cpp

    r98103 r99937  
    794794            while (cbToRead)
    795795            {
    796                 RTHTTPSERVER_HANDLE_CALLBACK_VA(pfnRead, pvHandle, pvBuf, RT_MIN(cbBuf, cbToRead), &cbRead);
     796                RTHTTPSERVER_HANDLE_CALLBACK_VA(pfnRead, pReq, pvHandle, pvBuf, RT_MIN(cbBuf, cbToRead), &cbRead);
    797797                if (RT_FAILURE(rc))
    798798                    break;
     
    815815        int rc2 = rc; /* Save rc. */
    816816
    817         RTHTTPSERVER_HANDLE_CALLBACK_VA(pfnClose, pvHandle);
     817        RTHTTPSERVER_HANDLE_CALLBACK_VA(pfnClose, pReq, pvHandle);
    818818
    819819        if (RT_FAILURE(rc2)) /* Restore original rc on failure. */
     
    963963            while (cbToRead)
    964964            {
    965                 RTHTTPSERVER_HANDLE_CALLBACK_VA(pfnRead, pvHandle, pvBuf, RT_MIN(cbBuf, cbToRead), &cbRead);
     965                RTHTTPSERVER_HANDLE_CALLBACK_VA(pfnRead, pReq, pvHandle, pvBuf, RT_MIN(cbBuf, cbToRead), &cbRead);
    966966                if (RT_FAILURE(rc))
    967967                    break;
     
    985985        int rc2 = rc; /* Save rc. */
    986986
    987         RTHTTPSERVER_HANDLE_CALLBACK_VA(pfnClose, pvHandle);
     987        RTHTTPSERVER_HANDLE_CALLBACK_VA(pfnClose, pReq, pvHandle);
    988988
    989989        if (RT_FAILURE(rc2)) /* Restore original rc on failure. */
     
    10211021                       || RTFS_IS_FILE(objInfo.Attr.fMode);
    10221022
    1023             /* No symlinks and other stuff not allowed. */
     1023            /* No symlinks and other stuff allowed. */
    10241024        }
    10251025        else
     
    11421142        /*
    11431143         * Parse HTTP version to use.
    1144          * We're picky heree: Only HTTP 1.1 is supported by now.
     1144         * We're picky here: Only HTTP 1.1 is supported by now.
    11451145         */
    11461146        const char *pszVer = ppapszFirstLine[2];
     
    12091209        LogFlowFunc(("Request %s %s\n", RTHttpMethodToStr(pReq->enmMethod), pReq->pszUrl));
    12101210
     1211        RTHTTPSERVER_HANDLE_CALLBACK_VA(pfnRequestBegin, pReq);
     1212
    12111213        unsigned i = 0;
    12121214        for (; i < RT_ELEMENTS(g_aMethodMap); i++)
     
    12251227        }
    12261228
     1229        RTHTTPSERVER_HANDLE_CALLBACK_VA(pfnRequestEnd, pReq);
     1230
    12271231        if (i == RT_ELEMENTS(g_aMethodMap))
    12281232            enmSts = RTHTTPSTATUS_NOTIMPLEMENTED;
     
    12331237        enmSts = RTHTTPSTATUS_BADREQUEST;
    12341238
    1235     if (enmSts != RTHTTPSTATUS_INTERNAL_NOT_SET)
    1236     {
    1237         int rc2 = rtHttpServerSendResponseSimple(pClient, enmSts);
    1238         if (RT_SUCCESS(rc))
    1239             rc = rc2;
    1240     }
     1239    /* Make sure to return at least *something* to the client, to prevent hangs. */
     1240    if (enmSts == RTHTTPSTATUS_INTERNAL_NOT_SET)
     1241        enmSts = RTHTTPSTATUS_INTERNALSERVERERROR;
     1242
     1243    int rc2 = rtHttpServerSendResponseSimple(pClient, enmSts);
     1244    if (RT_SUCCESS(rc))
     1245        rc = rc2;
    12411246
    12421247    LogFlowFuncLeaveRC(rc);
     
    12691274        if (RT_FAILURE(rc))
    12701275        {
    1271             LogFlowFunc(("RTTcpSelectOne=%Rrc (cWaitMs=%RU64)\n", rc, cWaitMs));
     1276            Log2Func(("RTTcpSelectOne=%Rrc (cWaitMs=%RU64)\n", rc, cWaitMs));
    12721277            if (rc == VERR_TIMEOUT)
    12731278            {
     
    12771282                        tsLastReadMs = RTTimeMilliTS();
    12781283                    const uint64_t tsDeltaMs = pClient->State.msKeepAlive - (RTTimeMilliTS() - tsLastReadMs);
    1279                     LogFlowFunc(("tsLastReadMs=%RU64, tsDeltaMs=%RU64\n", tsLastReadMs, tsDeltaMs));
    1280                     Log3Func(("Keep alive active (%RU32ms): %RU64ms remaining\n", pClient->State.msKeepAlive, tsDeltaMs));
     1284                    Log2Func(("tsLastReadMs=%RU64, tsDeltaMs=%RU64\n", tsLastReadMs, tsDeltaMs));
     1285                    Log2Func(("Keep alive active (%RU32ms): %RU64ms remaining\n", pClient->State.msKeepAlive, tsDeltaMs));
    12811286                    if (   tsDeltaMs > cWaitMs
    12821287                        && tsDeltaMs < pClient->State.msKeepAlive)
     
    13321337        } while (cbToRead);
    13331338
     1339        Log2Func(("Read client request done (%zu bytes) -> rc=%Rrc\n", cbReadTotal, rc));
     1340
    13341341        if (   RT_SUCCESS(rc)
    13351342            && cbReadTotal)
    13361343        {
    1337             LogFlowFunc(("Received client request (%zu bytes)\n", cbReadTotal));
    1338 
    13391344            rtHttpServerLogProto(pClient, false /* fWrite */, szReq);
    13401345
  • trunk/src/VBox/Runtime/tools/RTHttpServer.cpp

    r98103 r99937  
    521521}
    522522
    523 static DECLCALLBACK(int) onRead(PRTHTTPCALLBACKDATA pData, void *pvHandle, void *pvBuf, size_t cbBuf, size_t *pcbRead)
    524 {
     523static DECLCALLBACK(int) onRead(PRTHTTPCALLBACKDATA pData,
     524                                PRTHTTPSERVERREQ pReq, void *pvHandle, void *pvBuf, size_t cbBuf, size_t *pcbRead)
     525{
     526    RT_NOREF(pReq);
     527
    525528    PHTTPSERVERDATA pThis = (PHTTPSERVERDATA)pData->pvUser;
    526529    Assert(pData->cbUser == sizeof(HTTPSERVERDATA));
     
    554557}
    555558
    556 static DECLCALLBACK(int) onClose(PRTHTTPCALLBACKDATA pData, void *pvHandle)
    557 {
     559static DECLCALLBACK(int) onClose(PRTHTTPCALLBACKDATA pData, PRTHTTPSERVERREQ pReq, void *pvHandle)
     560{
     561    RT_NOREF(pReq);
     562
    558563    PHTTPSERVERDATA pThis = (PHTTPSERVERDATA)pData->pvUser;
    559564    Assert(pData->cbUser == sizeof(HTTPSERVERDATA));
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette