VirtualBox

Changeset 87020 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 1, 2020 11:26:13 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141612
Message:

Shared Clipboard/Transfers: Improved logging a bit. bugref:9874

File:
1 edited

Legend:

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

    r87018 r87020  
    427427
    428428/**
     429 * Logs the HTTP protocol communication to the debug logger (2).
     430 *
     431 * @param   pClient             Client to log communication for.
     432 * @param   fWrite              Whether the server is writing (to client) or reading (from client).
     433 * @param   pszData             Actual protocol communication data to log.
     434 */
     435static void rtHttpServerLogProto(PRTHTTPSERVERCLIENT pClient, bool fWrite, const char *pszData)
     436{
     437    RT_NOREF(pClient);
     438
     439    if (!pszData) /* Nothing to log? Bail out. */
     440        return;
     441
     442    char **ppapszStrings;
     443    size_t cStrings;
     444    int rc2 = RTStrSplit(pszData, strlen(pszData), "\r\n", &ppapszStrings, &cStrings);
     445    if (RT_SUCCESS(rc2))
     446    {
     447        for (size_t i = 0; i < cStrings; i++)
     448        {
     449            Log2(("%s %s\n", fWrite ? ">" : "<", ppapszStrings[i]));
     450            RTStrFree(ppapszStrings[i]);
     451        }
     452
     453        RTMemFree(ppapszStrings);
     454    }
     455}
     456
     457/**
     458 * Writes HTTP protocol communication data to a connected client.
     459 *
     460 * @returns VBox status code.
     461 * @param   pClient             Client to write data to.
     462 * @param   pszData             Data to write. Must be zero-terminated.
     463 */
     464static int rtHttpServerWriteProto(PRTHTTPSERVERCLIENT pClient, const char *pszData)
     465{
     466    rtHttpServerLogProto(pClient, true /* fWrite */, pszData);
     467    return RTTcpWrite(pClient->hSocket, pszData, strlen(pszData));
     468}
     469
     470/**
    429471 * Main function for sending a response back to the client.
    430472 *
     
    487529        rc = RTStrAAppend(&pszHdr, "\r\n");
    488530        if (RT_SUCCESS(rc))
    489             rc = RTTcpWrite(pClient->hSocket, pszHdr, strlen(pszHdr));
     531            rc = rtHttpServerWriteProto(pClient, pszHdr);
    490532    }
    491533
     
    9821024            && cbReadTotal)
    9831025        {
    984             LogFlowFunc(("Received request (%zu bytes):\n%s\n\n", cbReadTotal, pszReq));
     1026            LogFlowFunc(("Received client request (%zu bytes)\n", cbReadTotal));
     1027
     1028            rtHttpServerLogProto(pClient, false /* fWrite */, szReq);
    9851029
    9861030            rc = rtHttpServerProcessRequest(pClient, szReq, cbReadTotal);
Note: See TracChangeset for help on using the changeset viewer.

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